|
|
|
|
@@ -1,75 +1,77 @@
|
|
|
|
|
#include "Display.h"
|
|
|
|
|
#include "CharTable.h"
|
|
|
|
|
#include "Wire.h"
|
|
|
|
|
|
|
|
|
|
void Display::sendDisplayCMD(uint8_t cmd){
|
|
|
|
|
Wire.beginTransmission(DisplayAdress);
|
|
|
|
|
Wire.write(cmd_byte);
|
|
|
|
|
Wire.write(cmd);
|
|
|
|
|
Wire.endTransmission();
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
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(client,muxRatio);
|
|
|
|
|
sendDisplayCMD(client,0x3f);
|
|
|
|
|
sendDisplayCMD(muxRatio);
|
|
|
|
|
sendDisplayCMD(0x3f);
|
|
|
|
|
|
|
|
|
|
sendDisplayCMD(client,setOffset);
|
|
|
|
|
sendDisplayCMD(client,0x00);
|
|
|
|
|
sendDisplayCMD(setOffset);
|
|
|
|
|
sendDisplayCMD(0x00);
|
|
|
|
|
|
|
|
|
|
sendDisplayCMD(client, setStartLine);
|
|
|
|
|
sendDisplayCMD(setStartLine);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*x-flip*/
|
|
|
|
|
//sendDisplayCMD(client,setSegmentMap);
|
|
|
|
|
sendDisplayCMD(client, setSegmentReMap);
|
|
|
|
|
//sendDisplayCMD(setSegmentMap);
|
|
|
|
|
//sendDisplayCMD(setSegmentReMap);
|
|
|
|
|
|
|
|
|
|
/*mapping of the rows*/
|
|
|
|
|
sendDisplayCMD(client,setComHardwareConfig);
|
|
|
|
|
sendDisplayCMD(client,0x10);
|
|
|
|
|
//sendDisplayCMD(setComHardwareConfig);
|
|
|
|
|
//sendDisplayCMD(0x10);
|
|
|
|
|
|
|
|
|
|
/*y-flip*/
|
|
|
|
|
//sendDisplayCMD(client, setComDirectionNormal);
|
|
|
|
|
sendDisplayCMD(client, setComDirectionFlipped);
|
|
|
|
|
//sendDisplayCMD( setComDirectionNormal);
|
|
|
|
|
//sendDisplayCMD(setComDirectionFlipped);
|
|
|
|
|
|
|
|
|
|
sendDisplayCMD(client, setContrast);
|
|
|
|
|
sendDisplayCMD(client, 0x7f);
|
|
|
|
|
//sendDisplayCMD(setContrast);
|
|
|
|
|
//sendDisplayCMD(0x7f);
|
|
|
|
|
|
|
|
|
|
sendDisplayCMD(client,stopCompleteOn);
|
|
|
|
|
sendDisplayCMD(stopCompleteOn);
|
|
|
|
|
|
|
|
|
|
/*which pixels are bright: normal = 1s are bright, inverese= 0s are bright*/
|
|
|
|
|
sendDisplayCMD(client, setNormalMode);
|
|
|
|
|
//sendDisplayCMD(client, setInverseMode);
|
|
|
|
|
sendDisplayCMD( setNormalMode);
|
|
|
|
|
//sendDisplayCMD( setInverseMode);
|
|
|
|
|
|
|
|
|
|
sendDisplayCMD(client, setOscFreq);
|
|
|
|
|
sendDisplayCMD(client,0x80);
|
|
|
|
|
sendDisplayCMD( setOscFreq);
|
|
|
|
|
sendDisplayCMD(0x80);
|
|
|
|
|
|
|
|
|
|
sendDisplayCMD(client,setChargePump);
|
|
|
|
|
sendDisplayCMD(client,0x14);
|
|
|
|
|
sendDisplayCMD(setChargePump);
|
|
|
|
|
sendDisplayCMD(0x14);
|
|
|
|
|
|
|
|
|
|
sendDisplayCMD(client, activateDisplay);
|
|
|
|
|
sendDisplayCMD(activateDisplay);
|
|
|
|
|
for(int i = 0;i<128;i++){
|
|
|
|
|
Wire.beginTransmission(DisplayAdress);
|
|
|
|
|
Wire.write(0x00);
|
|
|
|
|
Wire.endTransmission();
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
void Display::clear(void){
|
|
|
|
|
|
|
|
|
|
int index=0;
|
|
|
|
|
sendDisplayCMD(client,addressingMode);
|
|
|
|
|
sendDisplayCMD(client,0x00); //horizontal
|
|
|
|
|
printk(KERN_ALERT "DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__);
|
|
|
|
|
sendDisplayCMD(client,colRange);
|
|
|
|
|
sendDisplayCMD(client,0x00);
|
|
|
|
|
sendDisplayCMD(client,0x7f);
|
|
|
|
|
printk(KERN_ALERT "DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__);
|
|
|
|
|
sendDisplayCMD(client,pageRange);
|
|
|
|
|
sendDisplayCMD(client,0x00);
|
|
|
|
|
sendDisplayCMD(client,0x07);
|
|
|
|
|
printk(KERN_ALERT "DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__);
|
|
|
|
|
i2c_data[0]=data_byte;
|
|
|
|
|
for(index=1;index<128*8;index++){i2c_data[index]=0x00;}
|
|
|
|
|
printk(KERN_ALERT "DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__);
|
|
|
|
|
Wire.beginTransmission(DisplayAdress);
|
|
|
|
|
Wire.write(data_byte);
|
|
|
|
|
Wire.endTransmission();
|
|
|
|
|
sendDisplayCMD(addressingMode);
|
|
|
|
|
sendDisplayCMD(0x00); //horizontal
|
|
|
|
|
sendDisplayCMD(colRange);
|
|
|
|
|
sendDisplayCMD(0x00);
|
|
|
|
|
sendDisplayCMD(0x7f);
|
|
|
|
|
sendDisplayCMD(pageRange);
|
|
|
|
|
sendDisplayCMD(0x00);
|
|
|
|
|
sendDisplayCMD(0x07);
|
|
|
|
|
//Wire only has a 32-Byte Buffer for transmission
|
|
|
|
|
for(uint index= 0; index<4;index++){
|
|
|
|
|
Wire.beginTransmission(DisplayAdress);
|
|
|
|
|
Wire.write(data_byte);
|
|
|
|
|
for(uint bufferIndex = 0;bufferIndex<32;bufferIndex++){
|
|
|
|
|
Wire.write(0x00);
|
|
|
|
|
}
|
|
|
|
|
@@ -83,7 +85,7 @@ void Display::clear(void){
|
|
|
|
|
*
|
|
|
|
|
* @param charAmount how many chars were added
|
|
|
|
|
*/
|
|
|
|
|
void Display::updateLine(int charAmount)
|
|
|
|
|
void Display::updateLine(uint charAmount)
|
|
|
|
|
{
|
|
|
|
|
if(charAmount+this->charsOnCurrLine>16)
|
|
|
|
|
{
|
|
|
|
|
@@ -92,16 +94,15 @@ void Display::updateLine(int charAmount)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this->charsOnCurrLine = this->charAmount+this->charsOnCurrLine;
|
|
|
|
|
this->charsOnCurrLine = charAmount+this->charsOnCurrLine;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Display::print(char *value){
|
|
|
|
|
int i = 0;
|
|
|
|
|
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=='/')
|
|
|
|
|
@@ -109,7 +110,7 @@ void Display::print(char *value){
|
|
|
|
|
nextchar = *value+1;
|
|
|
|
|
if(nextchar=='c')
|
|
|
|
|
{
|
|
|
|
|
Display::clearDisplay();
|
|
|
|
|
this->clear();
|
|
|
|
|
this->currLine = 0;
|
|
|
|
|
this->charsOnCurrLine = 0;
|
|
|
|
|
}
|
|
|
|
|
@@ -122,7 +123,7 @@ void Display::print(char *value){
|
|
|
|
|
}
|
|
|
|
|
while(this->charsOnCurrLine<17)
|
|
|
|
|
{
|
|
|
|
|
Wire.beginTransmission(Display_Adress);
|
|
|
|
|
Wire.beginTransmission(DisplayAdress);
|
|
|
|
|
for(int i = 0;i<9;i++){
|
|
|
|
|
Wire.write(font8x8_colwise[0][i]);
|
|
|
|
|
}
|
|
|
|
|
@@ -134,7 +135,6 @@ void Display::print(char *value){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
i=i+1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@@ -145,10 +145,8 @@ void Display::print(char *value){
|
|
|
|
|
}
|
|
|
|
|
Wire.endTransmission();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
value++;
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|