Compare commits
7
Commits
09a8a38509
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a322b36f9 | ||
|
|
1cdfc0dd46 | ||
|
|
1eb92e4ac2 | ||
|
|
1466d7d7b7 | ||
|
|
f5d468ca75 | ||
|
|
572ac11d4e | ||
|
|
67cfe20124 |
+1
-32
@@ -57,6 +57,7 @@ void AllClearCommand(char *symbols, int lenght){
|
|||||||
Fill(255);
|
Fill(255);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
ClearPages();
|
||||||
}
|
}
|
||||||
|
|
||||||
// command 2
|
// command 2
|
||||||
@@ -142,27 +143,6 @@ void DrawCharCommand(char *symbols, int lenght){
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Функция для вычисления контрольной суммы XOR
|
|
||||||
char CRC8(char *data, int length) {
|
|
||||||
char crc = 0x00;
|
|
||||||
char poly = 0x07; // полином для CRC8
|
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
crc ^= data[i]; // XOR текущего байта с crc
|
|
||||||
|
|
||||||
for (int j = 0; j < length; j++) {
|
|
||||||
if (crc & 0x80) { // если старший бит crc равен 1
|
|
||||||
crc = (crc << 1) ^ poly; // сдвигаем crc на 1 бит влево и XOR с полиномом
|
|
||||||
} else {
|
|
||||||
crc <<= 1; // иначе просто сдвигаем на 1 бит влево
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return crc;
|
|
||||||
}
|
|
||||||
|
|
||||||
char crc8(char *data, int len) {
|
char crc8(char *data, int len) {
|
||||||
char crc = 0x00;
|
char crc = 0x00;
|
||||||
while (len--) {
|
while (len--) {
|
||||||
@@ -177,14 +157,3 @@ char crc8(char *data, int len) {
|
|||||||
}
|
}
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Проверка массива на ноль
|
|
||||||
char checkArray(char *arr, int size) {
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
if (arr[i] != 0) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -26,10 +26,6 @@ void DrawCircleCommand(char *symbols, int lenght);
|
|||||||
void DrawRectangleCommand(char *symbols, int lenght);
|
void DrawRectangleCommand(char *symbols, int lenght);
|
||||||
void DrawCharCommand(char *symbols, int lenght);
|
void DrawCharCommand(char *symbols, int lenght);
|
||||||
|
|
||||||
|
|
||||||
char CRC8(char *data, int length);
|
|
||||||
char checkArray(char *arr, int size);
|
|
||||||
|
|
||||||
char crc8(char *data, int len);
|
char crc8(char *data, int len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ void Fill(uint8_t fill);
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
void DrawChar(uint8_t x, uint8_t y, uint8_t charIndex, uint8_t fill);
|
void DrawChar(uint8_t x, uint8_t y, uint8_t charIndex, uint8_t fill);
|
||||||
|
void ClearPages();
|
||||||
void AddSymbol(uint8_t symbol);
|
void AddSymbol(uint8_t symbol);
|
||||||
void DelSymbol();
|
void DelSymbol();
|
||||||
void SetPage(uint8_t p);
|
void SetPage(uint8_t p);
|
||||||
|
|||||||
@@ -292,6 +292,12 @@ void SetPage(uint8_t p){
|
|||||||
if (p > 8) page = 8;
|
if (p > 8) page = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClearPages(){
|
||||||
|
for (uint8_t row = 0; row < 8; row++) {
|
||||||
|
amountByteInPage[row] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AddSymbol(uint8_t symbol){
|
void AddSymbol(uint8_t symbol){
|
||||||
if (amountByteInPage[page] + 5 < 128){
|
if (amountByteInPage[page] + 5 < 128){
|
||||||
DrawChar(amountByteInPage[page],page*8,symbol,1);
|
DrawChar(amountByteInPage[page],page*8,symbol,1);
|
||||||
|
|||||||
+1
-35
@@ -14,60 +14,26 @@ ISR(SPI_STC_vect)
|
|||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(9600);
|
|
||||||
SPI_SlaveInit();
|
SPI_SlaveInit();
|
||||||
initialization();
|
initialization();
|
||||||
|
|
||||||
Fill(0);
|
Fill(0);
|
||||||
update();
|
update();
|
||||||
|
|
||||||
Serial.println();
|
|
||||||
Serial.println("Initialization ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Another
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Вывод массива
|
|
||||||
void arrayOut(uint8_t *arr, int size){
|
|
||||||
Serial.print("Array: ");
|
|
||||||
for(int i = 0; i < size;i++){
|
|
||||||
char str[3];
|
|
||||||
sprintf(str, "%02X", arr[i]);
|
|
||||||
Serial.print(str);
|
|
||||||
Serial.print(" ");
|
|
||||||
}
|
|
||||||
Serial.println(".");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
if(PINB & (1 << 2)){
|
if(PINB & (1 << 2)){
|
||||||
if(index > 0){
|
if(index > 0){
|
||||||
arrayOut(data, index);
|
|
||||||
|
|
||||||
char sum = 0;
|
char sum = 0;
|
||||||
sum = crc8(data, index-1);
|
sum = crc8(data, index-1);
|
||||||
|
|
||||||
char checkNull = 0;
|
|
||||||
char last_1 = data[index - 1];
|
char last_1 = data[index - 1];
|
||||||
|
|
||||||
Serial.println(sum, HEX);
|
|
||||||
|
|
||||||
if (last_1 == sum){
|
if (last_1 == sum){
|
||||||
Serial.println();
|
|
||||||
Serial.println("Старт вывода массивов");
|
|
||||||
Serial.println(sum, HEX);
|
|
||||||
|
|
||||||
SetCommand(data, index);
|
SetCommand(data, index);
|
||||||
// oled.print(data[0]);
|
|
||||||
Serial.println("Стоп вывода массивов");
|
|
||||||
index = 0;
|
index = 0;
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
Serial.println("Nothing ...");
|
|
||||||
|
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user