-->
Page 1 of 6

i2c OLED Module example

PostPosted: Mon Jan 19, 2015 6:46 am
by adamjp
I paid extra for this little oled, but for the ease of use it is excellent. oled: http://www.ebay.com.au/itm/251292095040

photo.JPG
photo.JPG (38.25 KiB) Viewed 6240 times


sample lua script:

Code: Select alli2c.setup(0, 4, 3, i2c.SLOW);
i2c.start(0);
i2c.address(0, 0x27, i2c.TRANSMITTER);
i2c.write(0, 0,"CL","TP",0,0,"TT","LFT",0,"TP",12,0,"TT","RGT",0,"TP",2,2,"TT","some here",0,"TP",4,4,"TT","some here",0);
i2c.stop(0);


letshaveabeer.JPG
letshaveabeer.JPG (36.94 KiB) Viewed 6144 times


Code: Select all-- self documenting long function name
function LetsHaveABeer(beer, ltrs, mids, temp)

   if beer == nil or ltrs == nil or mids == nil or temp == nil then
      print("Argument missing, need string:beer, string:ltrs, string:mids, string:temp");
   end
   --6,10,18,51,120,123,0
   i2c.setup(0, 4, 3, i2c.SLOW);
   i2c.start(0);
   i2c.address(0, 0x27, i2c.TRANSMITTER);
   -- battery
   -- between 1 - 10
   -- TODO
   power = 10;
   i2c.write(0, 0,"CL","DR",112,0,126,10,"LN",127,2,127,8,"FR",114,2,power+114,8);
   -- wifi 
   -- between 1 - 5
   -- TODO
   strength = 3;
   type = "FR";
   for i=0,4 do
      if strength <= i then
         type = "DR"
      end
      i2c.write(0,type,93+i*4,8-i*2,91+i*4,10); 
   end
   -- info
   i2c.write(0,"TP",0,0,"TT","T1 " .. temp.."C",0,"TP",2,2,"SF",18,"TT",beer,0,"SF",0,"TP",0,4,"TT",ltrs .."L",0,"TP",10,4,"TT", mids .. "M",0);
   i2c.stop(0);

end


Hopefully helps some projects along.
Cheers.

Re: i2c OLED Module example

PostPosted: Mon Jan 19, 2015 9:04 am
by alonewolfx2
It looks very easy but oled screen too expensive. Almost 16$.

Re: i2c OLED Module example

PostPosted: Mon Jan 19, 2015 3:44 pm
by adamjp
Is there any other lua example for cheaper oled modules?

Re: i2c OLED Module example

PostPosted: Mon Jan 19, 2015 4:31 pm
by Fr4gg0r
I would be interested in working c code for ssd1306 displays. So far mine stays black. :x