mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-05-22 04:21:49 +02:00
fixed clearDisplay(), changed linebreak to \n and added basic example
This commit is contained in:
parent
829adf435c
commit
a4a7bdc04b
17
example/display/basic/basic/basic.ino
Normal file
17
example/display/basic/basic/basic.ino
Normal file
@ -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();
|
||||||
|
}
|
@ -13,6 +13,7 @@ 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(muxRatio);
|
sendDisplayCMD(muxRatio);
|
||||||
sendDisplayCMD(0x3f);
|
sendDisplayCMD(0x3f);
|
||||||
|
|
||||||
@ -38,7 +39,6 @@ void Display::begin(void){
|
|||||||
//sendDisplayCMD(0x7f);
|
//sendDisplayCMD(0x7f);
|
||||||
|
|
||||||
sendDisplayCMD(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( setNormalMode);
|
sendDisplayCMD( setNormalMode);
|
||||||
//sendDisplayCMD( setInverseMode);
|
//sendDisplayCMD( setInverseMode);
|
||||||
@ -48,18 +48,11 @@ void Display::begin(void){
|
|||||||
|
|
||||||
sendDisplayCMD(setChargePump);
|
sendDisplayCMD(setChargePump);
|
||||||
sendDisplayCMD(0x14);
|
sendDisplayCMD(0x14);
|
||||||
|
|
||||||
sendDisplayCMD(activateDisplay);
|
sendDisplayCMD(activateDisplay);
|
||||||
for(int i = 0;i<128;i++){
|
this->clear();
|
||||||
Wire.beginTransmission(DisplayAdress);
|
|
||||||
Wire.write(0x00);
|
|
||||||
Wire.endTransmission();
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
void Display::clear(void){
|
void Display::clear(void){
|
||||||
|
|
||||||
int index=0;
|
|
||||||
sendDisplayCMD(addressingMode);
|
sendDisplayCMD(addressingMode);
|
||||||
sendDisplayCMD(0x00); //horizontal
|
sendDisplayCMD(0x00); //horizontal
|
||||||
sendDisplayCMD(colRange);
|
sendDisplayCMD(colRange);
|
||||||
@ -68,11 +61,10 @@ void Display::clear(void){
|
|||||||
sendDisplayCMD(pageRange);
|
sendDisplayCMD(pageRange);
|
||||||
sendDisplayCMD(0x00);
|
sendDisplayCMD(0x00);
|
||||||
sendDisplayCMD(0x07);
|
sendDisplayCMD(0x07);
|
||||||
//Wire only has a 32-Byte Buffer for transmission
|
for (int j=0;j<64;j++){
|
||||||
for(uint index= 0; index<4;index++){
|
|
||||||
Wire.beginTransmission(DisplayAdress);
|
Wire.beginTransmission(DisplayAdress);
|
||||||
Wire.write(data_byte);
|
Wire.write(data_byte);
|
||||||
for(uint bufferIndex = 0;bufferIndex<32;bufferIndex++){
|
for(int i = 0;i<16;i++){
|
||||||
Wire.write(0x00);
|
Wire.write(0x00);
|
||||||
}
|
}
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
@ -100,21 +92,15 @@ void Display::updateLine(uint charAmount)
|
|||||||
|
|
||||||
|
|
||||||
void Display::print(char *value){
|
void Display::print(char *value){
|
||||||
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=='\n')
|
||||||
{
|
{
|
||||||
nextchar = *value+1;
|
//value++;
|
||||||
if(nextchar=='c')
|
//if(*nextchar=='n')
|
||||||
{
|
|
||||||
this->clear();
|
|
||||||
this->currLine = 0;
|
|
||||||
this->charsOnCurrLine = 0;
|
|
||||||
}
|
|
||||||
else if(nextchar=='n')
|
|
||||||
{
|
{
|
||||||
if(this->charsOnCurrLine==16)
|
if(this->charsOnCurrLine==16)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user