Skip to content

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

arpunk
Copy link
Contributor

@arpunk arpunk commented Jan 14, 2024

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.

@arpunk arpunk marked this pull request as draft January 15, 2024 00:08
@arpunk arpunk marked this pull request as ready for review January 15, 2024 00:39
@arpunk arpunk marked this pull request as draft January 17, 2024 22:25
sda_pin => 21,
scl_pin => 22
},
SSD1306Config = #{sda_pin => 21,
Copy link
Collaborator

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,
Copy link
Collaborator

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, {
Copy link
Collaborator

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,
Copy link
Collaborator

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,
Copy link
Collaborator

@fadushin fadushin Jan 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants