73 lines
1.6 KiB
C++
73 lines
1.6 KiB
C++
#include "SPIMaster.h"
|
|
|
|
|
|
void Print(char *data2, int lenght){
|
|
for(int i = 0; i < lenght; i++) {
|
|
Serial.print(data2[i], HEX);
|
|
Serial.print(" ");
|
|
}
|
|
}
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(9600);
|
|
SPI_MasterInit();
|
|
Serial.println("Master Initialization ");
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
// All clear
|
|
// 0x00 - черный, остальное белое
|
|
// char data[] = {0x01, 0x00, 0};
|
|
|
|
// Setpage 1
|
|
// 0x00 - 0x07
|
|
// char data[] = {0x02, 0x01, 0};
|
|
|
|
// Add symbol
|
|
// char data[] = {0x03, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0F, 0};
|
|
|
|
// Delete symbol
|
|
// Кол-во символов
|
|
// char data[] = {0x04, 0x04, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0};
|
|
|
|
// Draw Pixel
|
|
// x, y, color
|
|
// char data[] = {0x05, 0x15, 0x15, 0x01, 0};
|
|
|
|
// Draw Line
|
|
// x1, y1, x2, y2, color
|
|
// char data[] = {0x06, 0x15, 0x15, 0x45, 0x45, 0x01, 0};
|
|
|
|
// Draw Circle
|
|
// x, y, r, color, fill
|
|
// char data[] = {0x07, 0x15, 0x15, 0x15, 0x01, 0x00, 0};
|
|
|
|
// Draw Rectangle
|
|
// x, y, width, height, color, fill
|
|
// char data[] = {0x08, 0x15, 0x15, 0x25, 0x25, 0x01, 0x00, 0};
|
|
|
|
// Draw Char
|
|
// x, y, charIndex, fill
|
|
// char data[] = {0x09, 0x15, 0x15, 0x05, 0x00, 0};
|
|
|
|
char data[] = {0x01, 0x00, 0};
|
|
int length = sizeof(data);
|
|
Serial.println();
|
|
Serial.print("Start: ");
|
|
Print(data, length);
|
|
Serial.println();
|
|
|
|
char checking = crc8(data, length-1);
|
|
int size = sizeof(data) / sizeof(data[0]);
|
|
data[size - 1] = checking;
|
|
Serial.println(checking, HEX);
|
|
|
|
Serial.print("End: ");
|
|
Print(data, length);
|
|
Serial.println();
|
|
|
|
SPI_MasterTransmit(data, length);
|
|
_delay_ms(5000);
|
|
} |