mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-07-05 10:04:31 +02:00
WIP: implementing basic displaycontrols
This commit is contained in:
157
src/display/Display.cpp
Normal file
157
src/display/Display.cpp
Normal file
@ -0,0 +1,157 @@
|
||||
#include Display.h
|
||||
|
||||
void Display::sendDisplayCMD(uint8_t cmd){
|
||||
|
||||
};
|
||||
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(client,setOffset);
|
||||
sendDisplayCMD(client,0x00);
|
||||
|
||||
sendDisplayCMD(client, setStartLine);
|
||||
|
||||
|
||||
/*x-flip*/
|
||||
//sendDisplayCMD(client,setSegmentMap);
|
||||
sendDisplayCMD(client, setSegmentReMap);
|
||||
|
||||
/*mapping of the rows*/
|
||||
sendDisplayCMD(client,setComHardwareConfig);
|
||||
sendDisplayCMD(client,0x10);
|
||||
|
||||
/*y-flip*/
|
||||
//sendDisplayCMD(client, setComDirectionNormal);
|
||||
sendDisplayCMD(client, setComDirectionFlipped);
|
||||
|
||||
sendDisplayCMD(client, setContrast);
|
||||
sendDisplayCMD(client, 0x7f);
|
||||
|
||||
sendDisplayCMD(client,stopCompleteOn);
|
||||
|
||||
/*which pixels are bright: normal = 1s are bright, inverese= 0s are bright*/
|
||||
sendDisplayCMD(client, setNormalMode);
|
||||
//sendDisplayCMD(client, setInverseMode);
|
||||
|
||||
sendDisplayCMD(client, setOscFreq);
|
||||
sendDisplayCMD(client,0x80);
|
||||
|
||||
sendDisplayCMD(client,setChargePump);
|
||||
sendDisplayCMD(client,0x14);
|
||||
|
||||
sendDisplayCMD(client, activateDisplay);
|
||||
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();
|
||||
//Wire only has a 32-Byte Buffer for transmission
|
||||
for(uint index= 0; index<4;index++){
|
||||
Wire.beginTransmission(DisplayAdress);
|
||||
for(uint bufferIndex = 0;bufferIndex<32;bufferIndex++){
|
||||
Wire.write(0x00);
|
||||
}
|
||||
Wire.endTransmission();
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief updates amount of chars on current rows and also the current row
|
||||
*
|
||||
* @param charAmount how many chars were added
|
||||
*/
|
||||
void Display::updateLine(int charAmount)
|
||||
{
|
||||
if(charAmount+this->charsOnCurrLine>16)
|
||||
{
|
||||
this->currLine = (this->currLine+((charAmount+this->charsOnCurrLine)/16))%8;
|
||||
this->charsOnCurrLine = (charAmount+this->charsOnCurrLine)%17; //there can be 0-16 chars on one line, so the 17th char is on next line
|
||||
}
|
||||
else
|
||||
{
|
||||
this->charsOnCurrLine = this->charAmount+this->charsOnCurrLine;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Display::print(char *value){
|
||||
int i = 0;
|
||||
int charval;
|
||||
int nextchar;
|
||||
/* write data to the buffer */
|
||||
//check if input is a predefined cmd
|
||||
for(i=0;i<count;i++) //count-1 to prevent the terminate string to be send
|
||||
{
|
||||
charval = procfs_buffer[i];
|
||||
if(charval=='/')
|
||||
{
|
||||
nextchar = procfs_buffer[i+1];
|
||||
if(nextchar=='c')
|
||||
{
|
||||
clearDisplay(display_i2c_client);
|
||||
currLine = 0;
|
||||
charsOnCurrLine = 0;
|
||||
}
|
||||
else if(nextchar=='n')
|
||||
{
|
||||
if(charsOnCurrLine==16)
|
||||
{
|
||||
currLine=currLine+1;
|
||||
charsOnCurrLine=0;
|
||||
}
|
||||
while(charsOnCurrLine<17)
|
||||
{
|
||||
i2c_master_send(display_i2c_client,font8x8_colwise[0],9);
|
||||
updateLine(1);
|
||||
if(charsOnCurrLine==16)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
i=i+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
updateLine(1);
|
||||
i2c_master_send(display_i2c_client,font8x8_colwise[charval],9);
|
||||
}
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
|
||||
return procfs_buffer_size;
|
||||
}
|
||||
};
|
||||
void Display::println(char *value){
|
||||
|
||||
};
|
||||
void Display::print(int value);
|
Reference in New Issue
Block a user