diff --git a/example/display/basic/basic/basic.ino b/example/display/basic/basic/basic.ino new file mode 100644 index 0000000..9d087e4 --- /dev/null +++ b/example/display/basic/basic/basic.ino @@ -0,0 +1,17 @@ +#include "Dezibot.h" + +Dezibot dezibot = Dezibot(); +void setup() { + // put your setup code here, to run once: + dezibot.begin(); +} + +void loop() { + // put your main code here, to run repeatedly: + dezibot.display.print("Hello from\nDezibot!"); + delay(5000); + dezibot.display.clear(); + dezibot.display.print("Bye!"); + delay(5000); + dezibot.display.clear(); +} diff --git a/src/display/Display.cpp b/src/display/Display.cpp index 1e7c29a..3a8369d 100644 --- a/src/display/Display.cpp +++ b/src/display/Display.cpp @@ -13,6 +13,7 @@ void Display::begin(void){ //TODO: change pin to #defines, first check if Wire.begin was already called Wire.begin(1,2); //set Mux Ratio + sendDisplayCMD(muxRatio); sendDisplayCMD(0x3f); @@ -38,7 +39,6 @@ void Display::begin(void){ //sendDisplayCMD(0x7f); sendDisplayCMD(stopCompleteOn); - /*which pixels are bright: normal = 1s are bright, inverese= 0s are bright*/ sendDisplayCMD( setNormalMode); //sendDisplayCMD( setInverseMode); @@ -48,18 +48,11 @@ void Display::begin(void){ sendDisplayCMD(setChargePump); sendDisplayCMD(0x14); - sendDisplayCMD(activateDisplay); - for(int i = 0;i<128;i++){ - Wire.beginTransmission(DisplayAdress); - Wire.write(0x00); - Wire.endTransmission(); - } + this->clear(); return; }; void Display::clear(void){ - - int index=0; sendDisplayCMD(addressingMode); sendDisplayCMD(0x00); //horizontal sendDisplayCMD(colRange); @@ -68,15 +61,14 @@ void Display::clear(void){ sendDisplayCMD(pageRange); sendDisplayCMD(0x00); sendDisplayCMD(0x07); - //Wire only has a 32-Byte Buffer for transmission - for(uint index= 0; index<4;index++){ + for (int j=0;j<64;j++){ Wire.beginTransmission(DisplayAdress); Wire.write(data_byte); - for(uint bufferIndex = 0;bufferIndex<32;bufferIndex++){ - Wire.write(0x00); + for(int i = 0;i<16;i++){ + Wire.write(0x00); } Wire.endTransmission(); - } + } return; }; @@ -100,21 +92,15 @@ void Display::updateLine(uint charAmount) void Display::print(char *value){ - char nextchar; + char *nextchar; /* write data to the buffer */ - while(value && value != "\0") //check if pointer is still valid and string is not terminated + while(value && *value != '\0') //check if pointer is still valid and string is not terminated { //check if input is a predefined cmd - if(*value=='/') + if(*value=='\n') { - nextchar = *value+1; - if(nextchar=='c') - { - this->clear(); - this->currLine = 0; - this->charsOnCurrLine = 0; - } - else if(nextchar=='n') + //value++; + //if(*nextchar=='n') { if(this->charsOnCurrLine==16) {