You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.1 KiB
81 lines
2.1 KiB
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include "lcdbuf.h"
|
|
|
|
int main()
|
|
{
|
|
struct LcdBuffer buf;
|
|
LcdBuffer_Init(&buf, CGROM_A00, CGRAM_CZ);
|
|
|
|
LcdBuffer_Write(&buf, 2, 10, "Ahoj");
|
|
LcdBuffer_Write(&buf, 2, 9, "x");
|
|
LcdBuffer_Write(&buf, 2, 6, "mm");
|
|
LcdBuffer_Write(&buf, 0, 0, "ěščžýíéů");
|
|
LcdBuffer_Write(&buf, 0, 0, "MEOWžýíéůěščřžýíéů");
|
|
|
|
LcdBuffer_Flush(&buf);
|
|
|
|
LcdBuffer_Write(&buf, 0, 5, "ĚŠČŘŽÝ");
|
|
|
|
LcdBuffer_Flush(&buf);
|
|
|
|
LcdBuffer_Clear(&buf);
|
|
LcdBuffer_Flush(&buf);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/** Write character data at position */
|
|
void LcdBuffer_IO_Clear()
|
|
{
|
|
printf("ClearScreen\n");
|
|
}
|
|
|
|
/** Write character data at position */
|
|
void LcdBuffer_IO_WriteAt(lcdbuf_pos_t row, lcdbuf_pos_t col, const uint8_t *buf, lcdbuf_count_t len)
|
|
{
|
|
printf("W@%d,%d: (len %d) \"", row, col, len); // "\n
|
|
for(int i=0; i<len; i++) {
|
|
char c = buf[i];
|
|
if (c >= 32 && c < 127) {
|
|
printf("%c", c);
|
|
} else {
|
|
printf("\\%d", c);
|
|
}
|
|
}
|
|
printf("\"\n");
|
|
}
|
|
|
|
#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
|
|
#define BYTE_TO_BINARY(byte) \
|
|
((byte) & 0x80 ? '#' : '.'), \
|
|
((byte) & 0x40 ? '#' : '.'), \
|
|
((byte) & 0x20 ? '#' : '.'), \
|
|
((byte) & 0x10 ? '#' : '.'), \
|
|
((byte) & 0x08 ? '#' : '.'), \
|
|
((byte) & 0x04 ? '#' : '.'), \
|
|
((byte) & 0x02 ? '#' : '.'), \
|
|
((byte) & 0x01 ? '#' : '.')
|
|
|
|
/** Write CGRAM data. Data is always 8 bytes long. */
|
|
void LcdBuffer_IO_WriteCGRAM(lcdbuf_pos_t position, const uint8_t *data)
|
|
{
|
|
printf("G@%d:\n "
|
|
BYTE_TO_BINARY_PATTERN"\n "
|
|
BYTE_TO_BINARY_PATTERN"\n "
|
|
BYTE_TO_BINARY_PATTERN"\n "
|
|
BYTE_TO_BINARY_PATTERN"\n "
|
|
BYTE_TO_BINARY_PATTERN"\n "
|
|
BYTE_TO_BINARY_PATTERN"\n "
|
|
BYTE_TO_BINARY_PATTERN"\n "
|
|
BYTE_TO_BINARY_PATTERN"\n\n",
|
|
position,
|
|
BYTE_TO_BINARY(data[0]),
|
|
BYTE_TO_BINARY(data[1]),
|
|
BYTE_TO_BINARY(data[2]),
|
|
BYTE_TO_BINARY(data[3]),
|
|
BYTE_TO_BINARY(data[4]),
|
|
BYTE_TO_BINARY(data[5]),
|
|
BYTE_TO_BINARY(data[6]),
|
|
BYTE_TO_BINARY(data[7]));
|
|
}
|
|
|