|
@@ -1,5 +1,6 @@
|
|
|
#include "main.h"
|
|
|
#include "font.h"
|
|
|
+#include "digits.h"
|
|
|
|
|
|
/* Private defines */
|
|
|
#define FRAMEBUFFER_ROTATE
|
|
@@ -7,7 +8,7 @@
|
|
|
/* Private constants */
|
|
|
#define MAX_COLUMN (DISPLAY_COLUMNS - 1)
|
|
|
#define FONT_WIDTH 6
|
|
|
-#define STR_BUF_SYM 40
|
|
|
+#define STR_BUF_SYM 50
|
|
|
#define STR_BUF_PAD (DISPLAY_COLUMNS / FONT_WIDTH)
|
|
|
#define STR_BUF_SIZE ((STR_BUF_PAD + STR_BUF_SYM + STR_BUF_PAD) * FONT_WIDTH)
|
|
|
|
|
@@ -27,6 +28,7 @@ static void _delay_c(uint32_t cycle);
|
|
|
void display_Init(void) {
|
|
|
/* Wait for SPI */
|
|
|
while ((SPI1->SR & SPI_SR_BSY) != 0) { __NOP(); }
|
|
|
+ display_Fill(0x0);
|
|
|
|
|
|
GPIO_SPI_SW();
|
|
|
HT1632C_CS_ON;
|
|
@@ -38,8 +40,6 @@ void display_Init(void) {
|
|
|
|
|
|
HT1632C_CS_OFF;
|
|
|
GPIO_SPI_HW();
|
|
|
-
|
|
|
- display_Fill(0x0);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -72,23 +72,21 @@ void display_String(const char * string, uint8_t repeat) {
|
|
|
if (string[0] == 0) { return; }
|
|
|
|
|
|
uint8_t str_buf[STR_BUF_SIZE] = {0};
|
|
|
- int i = 0, j = DISPLAY_COLUMNS;
|
|
|
+ int i = 0, j = DISPLAY_COLUMNS, k=0;
|
|
|
while ((string[i] != '\0') && (i < STR_BUF_SYM)) {
|
|
|
- str_buf[j] = string[i];
|
|
|
+ for(k=0; k<FONT_WIDTH; k++) {
|
|
|
+ str_buf[j] = Font_6x8[(uint8_t)string[i]][k];
|
|
|
+ j ++;
|
|
|
+ }
|
|
|
i ++;
|
|
|
- j ++;
|
|
|
}
|
|
|
|
|
|
- int k = 0;
|
|
|
while (repeat) {
|
|
|
- for (k=0; k<j; k++) {
|
|
|
- for (i=0; i<DISPLAY_COLUMNS; i++) {
|
|
|
- display_Buffer[i] = str_buf[k+i];
|
|
|
- }
|
|
|
- display_WriteBuffer();
|
|
|
- tdelay_ms(200);
|
|
|
+ for (k=0; k<=j; k++) {
|
|
|
+ display_WriteBuf(&str_buf[k]);
|
|
|
+ tdelay_ms(50);
|
|
|
}
|
|
|
- tdelay_ms(500);
|
|
|
+ tdelay_ms(200);
|
|
|
|
|
|
/* End of man loop */
|
|
|
repeat --;
|
|
@@ -268,6 +266,10 @@ void display_WriteData(const uint8_t * data, uint8_t addr, uint8_t len) {
|
|
|
* @brief Write all buffer to HT1632C
|
|
|
*/
|
|
|
void display_WriteBuffer(void) {
|
|
|
+ display_WriteBuf(display_Buffer);
|
|
|
+}
|
|
|
+
|
|
|
+void display_WriteBuf(const uint8_t * buf) {
|
|
|
/* Wait for SPI */
|
|
|
while ((SPI1->SR & SPI_SR_BSY) != 0) { __NOP(); }
|
|
|
|
|
@@ -277,34 +279,34 @@ void display_WriteBuffer(void) {
|
|
|
/* Rotate display buffer */
|
|
|
uint8_t i, j, p = 0x01;
|
|
|
for (i=0; i<8; i++) {
|
|
|
- if ((display_Buffer[0] & p) != 0) { spi_buf[i] |= 0x01; }
|
|
|
- if ((display_Buffer[1] & p) != 0) { spi_buf[i] |= 0x02; }
|
|
|
- if ((display_Buffer[2] & p) != 0) { spi_buf[i] |= 0x04; }
|
|
|
- if ((display_Buffer[3] & p) != 0) { spi_buf[i] |= 0x08; }
|
|
|
- if ((display_Buffer[4] & p) != 0) { spi_buf[i] |= 0x10; }
|
|
|
- if ((display_Buffer[5] & p) != 0) { spi_buf[i] |= 0x20; }
|
|
|
- if ((display_Buffer[6] & p) != 0) { spi_buf[i] |= 0x40; }
|
|
|
- if ((display_Buffer[7] & p) != 0) { spi_buf[i] |= 0x80; }
|
|
|
+ if ((buf[0] & p) != 0) { spi_buf[i] |= 0x01; }
|
|
|
+ if ((buf[1] & p) != 0) { spi_buf[i] |= 0x02; }
|
|
|
+ if ((buf[2] & p) != 0) { spi_buf[i] |= 0x04; }
|
|
|
+ if ((buf[3] & p) != 0) { spi_buf[i] |= 0x08; }
|
|
|
+ if ((buf[4] & p) != 0) { spi_buf[i] |= 0x10; }
|
|
|
+ if ((buf[5] & p) != 0) { spi_buf[i] |= 0x20; }
|
|
|
+ if ((buf[6] & p) != 0) { spi_buf[i] |= 0x40; }
|
|
|
+ if ((buf[7] & p) != 0) { spi_buf[i] |= 0x80; }
|
|
|
|
|
|
j = i + 8;
|
|
|
- if ((display_Buffer[8] & p) != 0) { spi_buf[j] |= 0x01; }
|
|
|
- if ((display_Buffer[9] & p) != 0) { spi_buf[j] |= 0x02; }
|
|
|
- if ((display_Buffer[10] & p) != 0) { spi_buf[j] |= 0x04; }
|
|
|
- if ((display_Buffer[11] & p) != 0) { spi_buf[j] |= 0x08; }
|
|
|
- if ((display_Buffer[12] & p) != 0) { spi_buf[j] |= 0x10; }
|
|
|
- if ((display_Buffer[13] & p) != 0) { spi_buf[j] |= 0x20; }
|
|
|
- if ((display_Buffer[14] & p) != 0) { spi_buf[j] |= 0x40; }
|
|
|
- if ((display_Buffer[15] & p) != 0) { spi_buf[j] |= 0x80; }
|
|
|
+ if ((buf[8] & p) != 0) { spi_buf[j] |= 0x01; }
|
|
|
+ if ((buf[9] & p) != 0) { spi_buf[j] |= 0x02; }
|
|
|
+ if ((buf[10] & p) != 0) { spi_buf[j] |= 0x04; }
|
|
|
+ if ((buf[11] & p) != 0) { spi_buf[j] |= 0x08; }
|
|
|
+ if ((buf[12] & p) != 0) { spi_buf[j] |= 0x10; }
|
|
|
+ if ((buf[13] & p) != 0) { spi_buf[j] |= 0x20; }
|
|
|
+ if ((buf[14] & p) != 0) { spi_buf[j] |= 0x40; }
|
|
|
+ if ((buf[15] & p) != 0) { spi_buf[j] |= 0x80; }
|
|
|
|
|
|
j = i + 16;
|
|
|
- if ((display_Buffer[16] & p) != 0) { spi_buf[j] |= 0x01; }
|
|
|
- if ((display_Buffer[17] & p) != 0) { spi_buf[j] |= 0x02; }
|
|
|
- if ((display_Buffer[18] & p) != 0) { spi_buf[j] |= 0x04; }
|
|
|
- if ((display_Buffer[19] & p) != 0) { spi_buf[j] |= 0x08; }
|
|
|
- if ((display_Buffer[20] & p) != 0) { spi_buf[j] |= 0x10; }
|
|
|
- if ((display_Buffer[21] & p) != 0) { spi_buf[j] |= 0x20; }
|
|
|
- if ((display_Buffer[22] & p) != 0) { spi_buf[j] |= 0x40; }
|
|
|
- if ((display_Buffer[23] & p) != 0) { spi_buf[j] |= 0x80; }
|
|
|
+ if ((buf[16] & p) != 0) { spi_buf[j] |= 0x01; }
|
|
|
+ if ((buf[17] & p) != 0) { spi_buf[j] |= 0x02; }
|
|
|
+ if ((buf[18] & p) != 0) { spi_buf[j] |= 0x04; }
|
|
|
+ if ((buf[19] & p) != 0) { spi_buf[j] |= 0x08; }
|
|
|
+ if ((buf[20] & p) != 0) { spi_buf[j] |= 0x10; }
|
|
|
+ if ((buf[21] & p) != 0) { spi_buf[j] |= 0x20; }
|
|
|
+ if ((buf[22] & p) != 0) { spi_buf[j] |= 0x40; }
|
|
|
+ if ((buf[23] & p) != 0) { spi_buf[j] |= 0x80; }
|
|
|
|
|
|
p <<= 1;
|
|
|
}
|