Commit 6efa14d3 authored by kamako's avatar kamako
Browse files

Add new file

parent ddcc039e
#include <stdio.h>
#include <inttypes.h>
#include "Serial_Backpack_LCD.h"
void clear_screen() {
uint8_t tx_buf[2] = {CONTROL, 0x00};
MSS_UART_polled_tx(&g_mss_uart1, tx_buf, sizeof(tx_buf));
}
void set_duty_cycle(uint8_t duty) {
uint8_t tx_buf[3] = {CONTROL, 0x02, duty};
MSS_UART_polled_tx(&g_mss_uart1, tx_buf, sizeof(tx_buf));
}
void set_baud_rate() {
uint8_t tx_buf[3] = {CONTROL, 0x07, 0x36};
MSS_UART_polled_tx(&g_mss_uart1, tx_buf, sizeof(tx_buf));
}
void set_coordinates(uint8_t x, uint8_t y) {
uint8_t tx_buf[3] = {CONTROL, 0x18, x};
MSS_UART_polled_tx(&g_mss_uart1, tx_buf, sizeof(tx_buf));
tx_buf[1] = 0x19;
tx_buf[2] = y;
MSS_UART_polled_tx(&g_mss_uart1, tx_buf, sizeof(tx_buf));
}
void set_reset_pixel(uint8_t x, uint8_t y, uint8_t set_reset) {
uint8_t tx_buf[5] = {CONTROL, 0x10, x, y, set_reset};
MSS_UART_polled_tx(&g_mss_uart1, tx_buf, sizeof(tx_buf));
}
void draw_erase_shape(shape_t shape, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t draw_erase) {
uint8_t tx_buf[7] = {CONTROL, -1, x1, y1, x2, y2, draw_erase};
switch(shape) {
case LINE:
tx_buf[1] = 0x0c;
break;
case CIRCLE:
tx_buf[1] = 0x03;
break;
case BOX:
tx_buf[1] = 0x0f;
break;
}
MSS_UART_polled_tx(&g_mss_uart1, tx_buf, sizeof(tx_buf));
}
void erase_block(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) {
uint8_t tx_buf[6] = {CONTROL, 0x05, x1, y1, x2, y2};
MSS_UART_polled_tx(&g_mss_uart1, tx_buf, sizeof(tx_buf));
}
void initialize(uint8_t duty) {
//initialize UART1
MSS_UART_init
(
&g_mss_uart1,
MSS_UART_115200_BAUD,
MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT
);
//initialize display
set_baud_rate();
//delay();
clear_screen();
//delay();
set_duty_cycle(duty);
//delay();
set_coordinates(0, 127);
//delay();
}
void display_inprogress() {
//{'P', 'r', 'i', 'n', 't', 'i', 'n', 'g', '.', '.', '.'}
uint8_t tx_buf[] = "Printing...";
set_coordinates(44, 80);
MSS_UART_polled_tx(&g_mss_uart1, tx_buf, sizeof(tx_buf)-1);
draw_erase_shape(BOX, BARSTART_X, BARSTART_Y, BAREND_X, BAREND_Y, 1);
}
void display_completed() {
//{'F', 'i', 'n', 'i', 's', 'h', 'e', 'd', '!'}
uint8_t tx_buf[] = "Finished!:D";
erase_block(44, 80, 159, 90);
set_coordinates(44, 80);
MSS_UART_polled_tx(&g_mss_uart1, tx_buf, sizeof(tx_buf)-1);
}
void fill(uint8_t start, uint8_t end) {
for (; start <= end; ++start) {
draw_erase_shape(LINE, start, BARSTART_Y, start, BAREND_Y, 1);
}
}
void delay() {
uint32_t i = 0;
for (; i < 1000000 ; ++i) {}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment