forked from wayoda/LedControl
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preparations for multilingual examples
- Loading branch information
Showing
11 changed files
with
683 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/** | ||
* @file LCDemo7Segment.ino | ||
* @author Noa Sakurajin ([email protected]) | ||
* @brief using the ledcontroller with 7-segment displays | ||
* @version 0.1 | ||
* @date 2020-12-30 | ||
* | ||
* @copyright Copyright (c) 2020 | ||
* | ||
*/ | ||
|
||
//We always have to include the library | ||
#include "LedController.hpp" | ||
|
||
/* | ||
You might need to change the following 3 Variables depending on your board. | ||
pin 15 is connected to the DataIn | ||
pin 14 is connected to the CLK | ||
pin 13 is connected to LOAD/ChipSelect | ||
*/ | ||
#define DIN 15 | ||
#define CS 13 | ||
#define CLK 14 | ||
|
||
/* | ||
Now we need a LedControl to work with. | ||
We have only a single MAX72XX. | ||
*/ | ||
LedController<1,1> lc; | ||
|
||
/* we always wait a bit between updates of the display */ | ||
unsigned long delaytime=250; | ||
|
||
void setup() { | ||
|
||
lc=LedController<1,1>(CS,CLK,DIN); | ||
|
||
/* | ||
The MAX72XX is in power-saving mode on startup, | ||
we have to do a wakeup call | ||
*/ | ||
lc.activateAllSegments(); | ||
/* Set the brightness to a medium values */ | ||
lc.setIntensity(8); | ||
/* and clear the display */ | ||
lc.clearMatrix(); | ||
} | ||
|
||
|
||
/* | ||
This method will display the characters for the | ||
word "Arduino" one after the other on digit 0. | ||
*/ | ||
void writeArduinoOn7Segment() { | ||
lc.setChar(0,0,'a',false); | ||
delay(delaytime); | ||
lc.setRow(0,0,0x05); | ||
delay(delaytime); | ||
lc.setChar(0,0,'d',false); | ||
delay(delaytime); | ||
lc.setRow(0,0,0x1c); | ||
delay(delaytime); | ||
lc.setRow(0,0,B00010000); | ||
delay(delaytime); | ||
lc.setRow(0,0,0x15); | ||
delay(delaytime); | ||
lc.setRow(0,0,0x1D); | ||
delay(delaytime); | ||
lc.clearMatrix(); | ||
delay(delaytime); | ||
} | ||
|
||
/* | ||
This method will scroll all the hexa-decimal | ||
numbers and letters on the display. You will need at least | ||
four 7-Segment digits. otherwise it won't really look that good. | ||
*/ | ||
void scrollDigits() { | ||
for(int i=0;i<13;i++) { | ||
lc.setDigit(0,3,i,false); | ||
lc.setDigit(0,2,i+1,false); | ||
lc.setDigit(0,1,i+2,false); | ||
lc.setDigit(0,0,i+3,false); | ||
delay(delaytime); | ||
} | ||
lc.clearMatrix(); | ||
delay(delaytime); | ||
} | ||
|
||
void loop() { | ||
writeArduinoOn7Segment(); | ||
scrollDigits(); | ||
} |
174 changes: 174 additions & 0 deletions
174
examples/german/LedControllerDemoCounting/LedControllerDemoCounting.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
/** | ||
* @file LedControllerDemoCounting.ino | ||
* @author Noa Sakurajin ([email protected]) | ||
* @brief counting up on an led matrix | ||
* @version 0.1 | ||
* @date 2020-12-30 | ||
* | ||
* @copyright Copyright (c) 2020 | ||
* | ||
*/ | ||
|
||
#include "LedController.hpp" | ||
|
||
//the pin where the chip select is connected to | ||
#define CS 15 | ||
|
||
#define Segments 4 | ||
|
||
#define delayTime 200 // Delay between Frames | ||
|
||
LedController<Segments,1> lc; | ||
|
||
//these are just some digits to display numbers on the matrix | ||
ByteBlock digits[10] = { | ||
{ | ||
B00000000, | ||
B00011000, | ||
B00100100, | ||
B01000010, | ||
B01000010, | ||
B00100100, | ||
B00011000, | ||
B00000000 | ||
}, { | ||
B00000000, | ||
B00011100, | ||
B00101100, | ||
B01001100, | ||
B00001100, | ||
B00001100, | ||
B00001100, | ||
B00000000 | ||
}, { | ||
B00000000, | ||
B00111000, | ||
B01101100, | ||
B00011000, | ||
B00110000, | ||
B01100000, | ||
B01111110, | ||
B00000000 | ||
}, { | ||
B00000000, | ||
B00111100, | ||
B01100110, | ||
B00001100, | ||
B00000110, | ||
B01100110, | ||
B00111100, | ||
B00000000 | ||
}, { | ||
B00000000, | ||
B01100000, | ||
B01100000, | ||
B01101000, | ||
B01111110, | ||
B00001000, | ||
B00001000, | ||
B00000000 | ||
}, { | ||
B00000000, | ||
B01111110, | ||
B01100000, | ||
B01111000, | ||
B00000110, | ||
B01100110, | ||
B00111100, | ||
B00000000 | ||
}, { | ||
B00000000, | ||
B00001100, | ||
B00111000, | ||
B01100000, | ||
B01111100, | ||
B01100110, | ||
B00111100, | ||
B00000000 | ||
}, { | ||
B00000000, | ||
B01111110, | ||
B00000110, | ||
B00001100, | ||
B00011000, | ||
B00110000, | ||
B01100000, | ||
B00000000 | ||
}, { | ||
B00000000, | ||
B00111100, | ||
B00100100, | ||
B00011000, | ||
B01100110, | ||
B01000010, | ||
B00111100, | ||
B00000000 | ||
}, { | ||
B00000000, | ||
B00111100, | ||
B01100110, | ||
B00111110, | ||
B00000110, | ||
B00011100, | ||
B00110000, | ||
B00000000 | ||
} | ||
}; | ||
|
||
//this function sets the matrix to a given number | ||
void setLEDs (unsigned int number) { | ||
//the loop is used to split the given number and set the right digit on the matix | ||
unsigned int places[4]; | ||
|
||
for(unsigned int i = 0;i < 4;i++){ | ||
unsigned int divisor = 1; | ||
for(unsigned int j=0;j < i;j++){ | ||
divisor *= 10; | ||
} | ||
|
||
places[3-i] = number/divisor % 10; | ||
lc.displayOnSegment(3-i,digits[places[3-i]]); | ||
} | ||
|
||
} | ||
|
||
//this function switches a led to have a | ||
void switchLED(){ | ||
static bool LEDON = false; | ||
if(LEDON){ | ||
digitalWrite(13, LOW); | ||
}else{ | ||
digitalWrite(13, HIGH); | ||
} | ||
LEDON = !LEDON; | ||
} | ||
|
||
void setup(){ | ||
|
||
//create a ledcontroller with a hardware spi and one row | ||
lc = LedController<Segments,1>(CS); | ||
|
||
//enable the led | ||
pinMode(13, OUTPUT); | ||
|
||
//rotate all digits by 180 degress to display them correctly | ||
//you could leave this but then the orientation would be wrong | ||
for(unsigned int i = 0; i < 10; i++){ | ||
digits[i] = lc.rotate180(digits[i]); | ||
} | ||
|
||
} | ||
|
||
void loop(){ | ||
|
||
//clear the matrix just to be sure there is nothing on it | ||
lc.clearMatrix(); | ||
|
||
//count up and display the number | ||
for (unsigned int i = 0; i<10000; i++) { | ||
delay(500); | ||
switchLED(); | ||
setLEDs(i); | ||
} | ||
|
||
} |
Oops, something went wrong.