-
Notifications
You must be signed in to change notification settings - Fork 2
Re-enable native Erlang driver #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
sda_pin => 21, | ||
scl_pin => 22 | ||
}, | ||
SSD1306Config = #{sda_pin => 21, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, my preference for formatting is to use 4-space indentation always (not a fan of traditional erlang/emacs formatting).
Some examples:
Map = #{
foo => bar,
bar => tapas
}.
PropList = [
{foo, bar},
{bar, tapas}
].
Fun = fun() ->
// do something
end.
%% file that be consult'd
{foo, [
{bar, [
{tapas, [one, two three] %% if it fits 80 cols
]}
]}.
nested(
function(
call([if, I, am, being, anal])
)
).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). | ||
-export([nif_init/1, nif_clear/1, nif_set_contrast/2, nif_set_text/2, nif_set_bitmap/4, nif_set_qrcode/2]). | ||
-export([start_link/1, | ||
start/1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation (please) :)
-spec start(Config::config()) -> {ok, SSD1306::ssd1306()} | {error, Reason::term()}. | ||
start(Config) -> | ||
gen_server:start(?MODULE, maps:merge(?DEFAULT_CONFIG, Config), []). | ||
-record(state, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
me gusta
case initialize_display(I2CBus, Address, Height, Width) of | ||
ok -> | ||
{ok, #state{ | ||
i2c_bus = I2CBus, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
% %% @private | ||
initialize_display(I2CBus, Address, _Height, _Weight) -> | ||
Data = << | ||
?CONTROL_BYTE_CMD_STREAM:8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation (etc). you get the idea
This PR fixes the initialization routine that allows the rest of the interface to work. It also wraps the I2C operations using the
i2c_bus
interface provided by atomvm_lib.This is a convenience wrapping since most devices with an OLED display will usually share the bus with more I2C devices.
The driver does not (yet) provide the rest of the features the NIF version provides, mainly displaying bitmaps and QR codes.
Further PRs will be aimed to address feature parity, cleaning up the configuration API, documentation and initialization options.