Skip to content

Commit 77b7ecf

Browse files
author
noasakurajin
authored
Merge pull request #38 from noah1510/restyled/2.0.x
Restyle 2.0.0-rc4
2 parents 3cff5f4 + b122543 commit 77b7ecf

File tree

23 files changed

+1614
-1512
lines changed

23 files changed

+1614
-1512
lines changed

examples/english/Led-matrix-counting/Led-matrix-counting.ino

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* @brief counting up on an led matrix
55
* @version 0.1
66
* @date 2020-12-30
7-
*
7+
*
88
* @copyright Copyright (c) 2020
9-
*
9+
*
1010
*/
1111

1212
#include "LedController.hpp"
@@ -18,7 +18,7 @@
1818

1919
#define delayTime 200 // Delay between Frames
2020

21-
LedController<Segments,1> lc;
21+
LedController<Segments,1> lc;
2222

2323
//these are just some digits to display numbers on the matrix
2424
ByteBlock digits[10] = {
@@ -120,9 +120,9 @@ void setLEDs (unsigned int number) {
120120
//the loop is used to split the given number and set the right digit on the matix
121121
unsigned int places[Segments];
122122

123-
for(unsigned int i = 0;i < Segments;i++){
123+
for(unsigned int i = 0; i < Segments; i++) {
124124
unsigned int divisor = 1;
125-
for(unsigned int j=0;j < i;j++){
125+
for(unsigned int j=0; j < i; j++) {
126126
divisor *= 10;
127127
}
128128

@@ -132,38 +132,38 @@ void setLEDs (unsigned int number) {
132132

133133
}
134134

135-
//this function switches a led to have a
136-
void switchLED(){
135+
//this function switches a led to have a
136+
void switchLED() {
137137
static bool LEDON = false;
138-
if(LEDON){
138+
if(LEDON) {
139139
digitalWrite(13, LOW);
140-
}else{
140+
} else {
141141
digitalWrite(13, HIGH);
142142
}
143143
LEDON = !LEDON;
144144
}
145145

146-
void setup(){
146+
void setup() {
147147

148148
//create a ledcontroller with a hardware spi and one row
149149
lc = LedController<Segments,1>(CS);
150150

151151
//enable the led
152152
pinMode(13, OUTPUT);
153-
153+
154154
//rotate all digits by 180 degress to display them correctly
155155
//you could leave this but then the orientation would be wrong
156-
for(unsigned int i = 0; i < 10; i++){
156+
for(unsigned int i = 0; i < 10; i++) {
157157
digits[i] = digits[i].rotate180();
158158
}
159-
159+
160160
}
161161

162-
void loop(){
162+
void loop() {
163163

164164
//clear the matrix just to be sure there is nothing on it
165165
lc.clearMatrix();
166-
166+
167167
//count up and display the number
168168
for (unsigned int i = 0; i<10000; i++) {
169169
delay(500);

examples/english/Led-matrix-message/Led-matrix-message.ino

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* This demo is based on https://www.meine-schaltung.de/schaltung/soft/anzeige/vierfach_matrix_mit_arduino/ and modified for the latest LedController.
66
* @version 0.1
77
* @date 2021-02-16
8-
*
8+
*
99
* @copyright Copyright (c) 2021
10-
*
10+
*
1111
*/
1212

1313
//As always include the library
@@ -24,7 +24,7 @@
2424
#define delayTime 200
2525

2626
//The ledController object, at the moment it is uninitilized
27-
LedController<Segments,1> lc = LedController<Segments,1>();
27+
LedController<Segments,1> lc = LedController<Segments,1>();
2828

2929
// Symbols and Letters ---------------------------------------------------------------------------------
3030
ByteBlock A = ByteBlock::rotate180({ B00000000, B00011000, B00100100, B00100100, B00111100, B00100100, B00100100, B00000000 });
@@ -81,7 +81,7 @@ ByteBlock message[message_length] = {
8181
};
8282

8383

84-
void setup(){
84+
void setup() {
8585
//setup the config with the same size as the controller
8686
controller_configuration<Segments,1> conf;
8787
//use the specified CS pin
@@ -98,25 +98,25 @@ void setup(){
9898
lc.setIntensity(0);
9999
}
100100

101-
void loop(){
102-
//clear just to be safe
103-
lc.clearMatrix();
104-
105-
//shift data in
106-
//each segment of the message will be shifted in one by one
107-
for(unsigned int i = 0;i < message_length;i++){
108-
//since each segment has a width of 8 pixels there is another loop
109-
for(unsigned int j = 0;j < 8;j++){
110-
//move the columns in one by one and wait a bit
111-
lc.moveLeft(ByteBlock::makeColumns(message[i])[j]);
112-
delay(delayTime);
113-
}
114-
}
115-
116-
//shift the contents out
117-
//since the sice is 8*segments simply shift left that many times
118-
for(unsigned int i = 0; i < 8*Segments;i++){
119-
lc.moveLeft();
101+
void loop() {
102+
//clear just to be safe
103+
lc.clearMatrix();
104+
105+
//shift data in
106+
//each segment of the message will be shifted in one by one
107+
for(unsigned int i = 0; i < message_length; i++) {
108+
//since each segment has a width of 8 pixels there is another loop
109+
for(unsigned int j = 0; j < 8; j++) {
110+
//move the columns in one by one and wait a bit
111+
lc.moveLeft(ByteBlock::makeColumns(message[i])[j]);
120112
delay(delayTime);
121113
}
114+
}
115+
116+
//shift the contents out
117+
//since the sice is 8*segments simply shift left that many times
118+
for(unsigned int i = 0; i < 8*Segments; i++) {
119+
lc.moveLeft();
120+
delay(delayTime);
121+
}
122122
}

examples/english/Led-matrix-rocket-hwSPI/Led-matrix-rocket-hwSPI.ino

100755100644
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* @brief Led-matrix-rocket.ino with hardware spi
55
* @version 0.1
66
* @date 2020-12-30
7-
*
7+
*
88
* @copyright Copyright (c) 2020
9-
*
9+
*
1010
*/
1111

1212
//Since this is just Led-matrix-rocket.ino with hardware SPI, view its site for more details.
@@ -17,7 +17,7 @@
1717

1818
#define delayTime 200
1919

20-
LedController<Segments,1> lc = LedController<Segments,1>();
20+
LedController<Segments,1> lc = LedController<Segments,1>();
2121

2222
ByteBlock rocket= ByteBlock::reverse({
2323
B00000000,
@@ -32,17 +32,17 @@ ByteBlock rocket= ByteBlock::reverse({
3232

3333
ByteBlock rocketColumns;
3434

35-
void switchLED(){
35+
void switchLED() {
3636
static bool LEDON = false;
37-
if(LEDON){
37+
if(LEDON) {
3838
digitalWrite(13, LOW);
39-
}else{
39+
} else {
4040
digitalWrite(13, HIGH);
4141
}
4242
LEDON = !LEDON;
4343
}
4444

45-
void setup(){
45+
void setup() {
4646
//Only the following line is different from the example without hardware SPI since in this case only one Pin needs to be specified
4747
lc.init(CS);
4848

@@ -51,39 +51,39 @@ void setup(){
5151
pinMode(13, OUTPUT);
5252

5353
lc.setIntensity(0);
54-
54+
5555
}
5656

57-
void loop(){
58-
59-
lc.clearMatrix();
60-
61-
for(int dir = 0; dir < 2;dir++){
57+
void loop() {
58+
59+
lc.clearMatrix();
60+
61+
for(int dir = 0; dir < 2; dir++) {
62+
delay(delayTime);
63+
for(int i = 0; i < 8*(Segments+1); i++) {
64+
//blink led for each iteration
65+
switchLED();
66+
67+
//if rocket not fully inside let it fly in
68+
auto in = (i<8) ? rocketColumns[i] : 0x00;
69+
70+
//if dir is 0 move right if not move left
71+
dir == 0 ? lc.moveRight(in) : lc.moveLeft(in);
72+
6273
delay(delayTime);
63-
for(int i = 0;i < 8*(Segments+1);i++){
64-
//blink led for each iteration
65-
switchLED();
66-
67-
//if rocket not fully inside let it fly in
68-
auto in = (i<8) ? rocketColumns[i] : 0x00;
69-
70-
//if dir is 0 move right if not move left
71-
dir == 0 ? lc.moveRight(in) : lc.moveLeft(in);
72-
73-
delay(delayTime);
74-
75-
//decide whether to move up or down
76-
if(i > 7){
77-
if(i % 6 < 3){
78-
lc.moveDown();
79-
}else{
80-
lc.moveUp();
81-
}
74+
75+
//decide whether to move up or down
76+
if(i > 7) {
77+
if(i % 6 < 3) {
78+
lc.moveDown();
79+
} else {
80+
lc.moveUp();
8281
}
82+
}
8383

84-
delay(delayTime);
84+
delay(delayTime);
8585

86-
}
8786
}
87+
}
8888

8989
}

examples/english/Led-matrix-rocket-multi/Led-matrix-rocket-multi.ino

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* @brief An exaple for using multiple rows
55
* @version 0.1
66
* @date 2020-12-30
7-
*
7+
*
88
* @copyright Copyright (c) 2020
9-
*
9+
*
1010
*/
1111

1212
#include "LedController.hpp"
@@ -46,17 +46,17 @@ ByteBlock rocket= ByteBlock::reverse({
4646
ByteBlock rocketColumns;
4747

4848
//switches the state of the builtin led
49-
void switchLED(){
49+
void switchLED() {
5050
static bool LEDON = false;
51-
if(LEDON){
51+
if(LEDON) {
5252
digitalWrite(LED, LOW);
53-
}else{
53+
} else {
5454
digitalWrite(LED, HIGH);
5555
}
5656
LEDON = !LEDON;
5757
}
5858

59-
void setup(){
59+
void setup() {
6060

6161
//creating the configuration of the controller
6262
controller_configuration<Segments,2> conf;
@@ -90,53 +90,53 @@ void setup(){
9090

9191
//enables the builtin Led to have a kind of clock
9292
pinMode(LED, OUTPUT);
93-
93+
9494
}
9595

9696
//This is basically the same as Led-matrix-rocket.ino
97-
void loop(){
97+
void loop() {
9898
lc.clearMatrix();
99-
100-
for(int i = 0;i < 8*(Segments+1);i++){
99+
100+
for(int i = 0; i < 8*(Segments+1); i++) {
101101
delay(delayTime);
102102

103103
switchLED();
104104

105-
if(i < 8){
106-
lc.moveRowRight(rocketColumns[i]);
107-
}else{
105+
if(i < 8) {
106+
lc.moveRowRight(rocketColumns[i]);
107+
} else {
108108
lc.moveRight();
109109

110110
delay(delayTime);
111-
if(i%16 < 8){
111+
if(i%16 < 8) {
112112
lc.moveDown();
113-
}else{
113+
} else {
114114
lc.moveUp();
115115
}
116116
}
117-
117+
118118
}
119119

120120
delay(delayTime);
121121

122-
for(int i = 0;i < 8*(Segments+1);i++){
122+
for(int i = 0; i < 8*(Segments+1); i++) {
123123
delay(delayTime);
124124

125125
switchLED();
126126

127-
if(i < 8){
128-
lc.moveRowLeft(rocketColumns[i]);
129-
}else{
127+
if(i < 8) {
128+
lc.moveRowLeft(rocketColumns[i]);
129+
} else {
130130
lc.moveLeft();
131131

132132
delay(delayTime);
133-
if(i%16 < 8){
133+
if(i%16 < 8) {
134134
lc.moveDown();
135-
}else{
135+
} else {
136136
lc.moveUp();
137137
}
138138
}
139-
139+
140140
}
141141

142142
delay(delayTime);

0 commit comments

Comments
 (0)