mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-07-04 09:41:43 +02:00
first working version, but still prints a junkdata after the text, formatstrings doesn't work
This commit is contained in:
@ -15,10 +15,11 @@
|
||||
Dezibot::Dezibot():multiColorLight(){};
|
||||
|
||||
void Dezibot::begin(void) {
|
||||
infraredLight.begin();
|
||||
lightDetection.begin();
|
||||
motion.begin();
|
||||
multiColorLight.begin();
|
||||
//infraredLight.begin();
|
||||
//lightDetection.begin();
|
||||
//motion.begin();
|
||||
//multiColorLight.begin();
|
||||
display.begin();
|
||||
};
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "multiColorLight/MultiColorLight.h"
|
||||
#include "motionDetection/MotionDetection.h"
|
||||
#include "infraredLight/InfraredLight.h"
|
||||
#include "display/Display.h"
|
||||
|
||||
|
||||
class Dezibot {
|
||||
@ -30,6 +31,7 @@ public:
|
||||
MultiColorLight multiColorLight;
|
||||
MotionDetection motionDetection;
|
||||
InfraredLight infraredLight;
|
||||
Display display;
|
||||
void begin(void);
|
||||
/*
|
||||
Display display
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
|
@ -21,4 +21,4 @@
|
||||
#define colRange 0x21
|
||||
#define pageRange 0x22
|
||||
|
||||
#define DisplayAdress
|
||||
#define DisplayAdress 0x3C
|
Reference in New Issue
Block a user