-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
64 lines (59 loc) · 1.15 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <Arduino.h>
#include <LedControl.h>
#include <Wire.h>
#include "PriUint64.h"
const int DIN_PIN = 10;
const int CS_PIN = 9;
const int CLK_PIN = 8;
LedControl display = LedControl(DIN_PIN, CLK_PIN, CS_PIN);
void displayImage(uint64_t image)
{
for (int i = 0; i < 8; i++)
{
byte row = (image >> i * 8) & 0xFF;
for (int j = 0; j < 8; j++)
{
display.setLed(0, i, j, bitRead(row, 7 - j));
}
}
}
uint64_t convertStringToU64(String str)
{
uint64_t val = 0;
for (unsigned int i = 0; i < str.length(); i++)
{
val = val * 10;
val = val + str[i] - '0';
}
return val;
}
void setup()
{
Serial.begin(115200);
display.clearDisplay(0);
display.shutdown(0, false);
display.setIntensity(0, 10);
}
int k = 0;
int j = 0;
int64_t image = 0;
String readString = "";
void loop()
{
while (Serial.available())
{
char c = Serial.read();
Serial.print(c);
if (c != '\n')
readString += c;
else
{
Serial.print(readString + "|");
image = convertStringToU64(readString);
Serial.println(PriUint64<DEC>(image));
displayImage(image);
readString = "";
delay(3.32);
}
}
}