mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-07-04 17:51:41 +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(){};
|
Dezibot::Dezibot():multiColorLight(){};
|
||||||
|
|
||||||
void Dezibot::begin(void) {
|
void Dezibot::begin(void) {
|
||||||
infraredLight.begin();
|
//infraredLight.begin();
|
||||||
lightDetection.begin();
|
//lightDetection.begin();
|
||||||
motion.begin();
|
//motion.begin();
|
||||||
multiColorLight.begin();
|
//multiColorLight.begin();
|
||||||
|
display.begin();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "multiColorLight/MultiColorLight.h"
|
#include "multiColorLight/MultiColorLight.h"
|
||||||
#include "motionDetection/MotionDetection.h"
|
#include "motionDetection/MotionDetection.h"
|
||||||
#include "infraredLight/InfraredLight.h"
|
#include "infraredLight/InfraredLight.h"
|
||||||
|
#include "display/Display.h"
|
||||||
|
|
||||||
|
|
||||||
class Dezibot {
|
class Dezibot {
|
||||||
@ -30,6 +31,7 @@ public:
|
|||||||
MultiColorLight multiColorLight;
|
MultiColorLight multiColorLight;
|
||||||
MotionDetection motionDetection;
|
MotionDetection motionDetection;
|
||||||
InfraredLight infraredLight;
|
InfraredLight infraredLight;
|
||||||
|
Display display;
|
||||||
void begin(void);
|
void begin(void);
|
||||||
/*
|
/*
|
||||||
Display display
|
Display display
|
||||||
|
@ -1,75 +1,77 @@
|
|||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
#include "CharTable.h"
|
#include "CharTable.h"
|
||||||
|
#include "Wire.h"
|
||||||
|
|
||||||
void Display::sendDisplayCMD(uint8_t cmd){
|
void Display::sendDisplayCMD(uint8_t cmd){
|
||||||
|
Wire.beginTransmission(DisplayAdress);
|
||||||
|
Wire.write(cmd_byte);
|
||||||
|
Wire.write(cmd);
|
||||||
|
Wire.endTransmission();
|
||||||
|
|
||||||
};
|
};
|
||||||
void Display::begin(void){
|
void Display::begin(void){
|
||||||
//TODO: change pin to #defines, first check if Wire.begin was already called
|
//TODO: change pin to #defines, first check if Wire.begin was already called
|
||||||
Wire.begin(1,2);
|
Wire.begin(1,2);
|
||||||
//set Mux Ratio
|
//set Mux Ratio
|
||||||
sendDisplayCMD(client,muxRatio);
|
sendDisplayCMD(muxRatio);
|
||||||
sendDisplayCMD(client,0x3f);
|
sendDisplayCMD(0x3f);
|
||||||
|
|
||||||
sendDisplayCMD(client,setOffset);
|
sendDisplayCMD(setOffset);
|
||||||
sendDisplayCMD(client,0x00);
|
sendDisplayCMD(0x00);
|
||||||
|
|
||||||
sendDisplayCMD(client, setStartLine);
|
sendDisplayCMD(setStartLine);
|
||||||
|
|
||||||
|
|
||||||
/*x-flip*/
|
/*x-flip*/
|
||||||
//sendDisplayCMD(client,setSegmentMap);
|
//sendDisplayCMD(setSegmentMap);
|
||||||
sendDisplayCMD(client, setSegmentReMap);
|
//sendDisplayCMD(setSegmentReMap);
|
||||||
|
|
||||||
/*mapping of the rows*/
|
/*mapping of the rows*/
|
||||||
sendDisplayCMD(client,setComHardwareConfig);
|
//sendDisplayCMD(setComHardwareConfig);
|
||||||
sendDisplayCMD(client,0x10);
|
//sendDisplayCMD(0x10);
|
||||||
|
|
||||||
/*y-flip*/
|
/*y-flip*/
|
||||||
//sendDisplayCMD(client, setComDirectionNormal);
|
//sendDisplayCMD( setComDirectionNormal);
|
||||||
sendDisplayCMD(client, setComDirectionFlipped);
|
//sendDisplayCMD(setComDirectionFlipped);
|
||||||
|
|
||||||
sendDisplayCMD(client, setContrast);
|
//sendDisplayCMD(setContrast);
|
||||||
sendDisplayCMD(client, 0x7f);
|
//sendDisplayCMD(0x7f);
|
||||||
|
|
||||||
sendDisplayCMD(client,stopCompleteOn);
|
sendDisplayCMD(stopCompleteOn);
|
||||||
|
|
||||||
/*which pixels are bright: normal = 1s are bright, inverese= 0s are bright*/
|
/*which pixels are bright: normal = 1s are bright, inverese= 0s are bright*/
|
||||||
sendDisplayCMD(client, setNormalMode);
|
sendDisplayCMD( setNormalMode);
|
||||||
//sendDisplayCMD(client, setInverseMode);
|
//sendDisplayCMD( setInverseMode);
|
||||||
|
|
||||||
sendDisplayCMD(client, setOscFreq);
|
sendDisplayCMD( setOscFreq);
|
||||||
sendDisplayCMD(client,0x80);
|
sendDisplayCMD(0x80);
|
||||||
|
|
||||||
sendDisplayCMD(client,setChargePump);
|
sendDisplayCMD(setChargePump);
|
||||||
sendDisplayCMD(client,0x14);
|
sendDisplayCMD(0x14);
|
||||||
|
|
||||||
sendDisplayCMD(client, activateDisplay);
|
sendDisplayCMD(activateDisplay);
|
||||||
|
for(int i = 0;i<128;i++){
|
||||||
|
Wire.beginTransmission(DisplayAdress);
|
||||||
|
Wire.write(0x00);
|
||||||
|
Wire.endTransmission();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
void Display::clear(void){
|
void Display::clear(void){
|
||||||
|
|
||||||
int index=0;
|
int index=0;
|
||||||
sendDisplayCMD(client,addressingMode);
|
sendDisplayCMD(addressingMode);
|
||||||
sendDisplayCMD(client,0x00); //horizontal
|
sendDisplayCMD(0x00); //horizontal
|
||||||
printk(KERN_ALERT "DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__);
|
sendDisplayCMD(colRange);
|
||||||
sendDisplayCMD(client,colRange);
|
sendDisplayCMD(0x00);
|
||||||
sendDisplayCMD(client,0x00);
|
sendDisplayCMD(0x7f);
|
||||||
sendDisplayCMD(client,0x7f);
|
sendDisplayCMD(pageRange);
|
||||||
printk(KERN_ALERT "DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__);
|
sendDisplayCMD(0x00);
|
||||||
sendDisplayCMD(client,pageRange);
|
sendDisplayCMD(0x07);
|
||||||
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
|
//Wire only has a 32-Byte Buffer for transmission
|
||||||
for(uint index= 0; index<4;index++){
|
for(uint index= 0; index<4;index++){
|
||||||
Wire.beginTransmission(DisplayAdress);
|
Wire.beginTransmission(DisplayAdress);
|
||||||
|
Wire.write(data_byte);
|
||||||
for(uint bufferIndex = 0;bufferIndex<32;bufferIndex++){
|
for(uint bufferIndex = 0;bufferIndex<32;bufferIndex++){
|
||||||
Wire.write(0x00);
|
Wire.write(0x00);
|
||||||
}
|
}
|
||||||
@ -83,7 +85,7 @@ void Display::clear(void){
|
|||||||
*
|
*
|
||||||
* @param charAmount how many chars were added
|
* @param charAmount how many chars were added
|
||||||
*/
|
*/
|
||||||
void Display::updateLine(int charAmount)
|
void Display::updateLine(uint charAmount)
|
||||||
{
|
{
|
||||||
if(charAmount+this->charsOnCurrLine>16)
|
if(charAmount+this->charsOnCurrLine>16)
|
||||||
{
|
{
|
||||||
@ -92,16 +94,15 @@ void Display::updateLine(int charAmount)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->charsOnCurrLine = this->charAmount+this->charsOnCurrLine;
|
this->charsOnCurrLine = charAmount+this->charsOnCurrLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Display::print(char *value){
|
void Display::print(char *value){
|
||||||
int i = 0;
|
|
||||||
char nextchar;
|
char nextchar;
|
||||||
/* write data to the buffer */
|
/* 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
|
//check if input is a predefined cmd
|
||||||
if(*value=='/')
|
if(*value=='/')
|
||||||
@ -109,7 +110,7 @@ void Display::print(char *value){
|
|||||||
nextchar = *value+1;
|
nextchar = *value+1;
|
||||||
if(nextchar=='c')
|
if(nextchar=='c')
|
||||||
{
|
{
|
||||||
Display::clearDisplay();
|
this->clear();
|
||||||
this->currLine = 0;
|
this->currLine = 0;
|
||||||
this->charsOnCurrLine = 0;
|
this->charsOnCurrLine = 0;
|
||||||
}
|
}
|
||||||
@ -122,7 +123,7 @@ void Display::print(char *value){
|
|||||||
}
|
}
|
||||||
while(this->charsOnCurrLine<17)
|
while(this->charsOnCurrLine<17)
|
||||||
{
|
{
|
||||||
Wire.beginTransmission(Display_Adress);
|
Wire.beginTransmission(DisplayAdress);
|
||||||
for(int i = 0;i<9;i++){
|
for(int i = 0;i<9;i++){
|
||||||
Wire.write(font8x8_colwise[0][i]);
|
Wire.write(font8x8_colwise[0][i]);
|
||||||
}
|
}
|
||||||
@ -134,7 +135,6 @@ void Display::print(char *value){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i=i+1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -145,10 +145,8 @@ void Display::print(char *value){
|
|||||||
}
|
}
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
}
|
}
|
||||||
|
value++;
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -21,4 +21,4 @@
|
|||||||
#define colRange 0x21
|
#define colRange 0x21
|
||||||
#define pageRange 0x22
|
#define pageRange 0x22
|
||||||
|
|
||||||
#define DisplayAdress
|
#define DisplayAdress 0x3C
|
Reference in New Issue
Block a user