add ui, change project struct

This commit is contained in:
Sheikah
2023-01-23 16:39:02 +08:00
parent 5f59f9412a
commit df4db6d8c4
150 changed files with 931 additions and 741 deletions

View File

@ -1,388 +0,0 @@
#include <app.h>
#include <main.h>
#include <st7735.h>
#include <RotaryCoder.h>
#include <KT0915.h>
/*Arduino APP 未移植 不可用*/
uint8_t app_setup(void){
}
/*
Shows the static content on display
*/
void showTemplate()
{
int maxX1 = tft.width() - 2;
int maxY1 = tft.height() - 5;
tft.fillScreen(COLOR_BLACK);
tft.drawRect(2, 2, maxX1, maxY1, COLOR_YELLOW);
tft.drawLine(2, 40, maxX1, 40, COLOR_YELLOW);
tft.drawLine(2, 60, maxX1, 60, COLOR_YELLOW);
}
void clearStatus()
{
char *unit;
char *bandMode;
int maxX1 = tft.width() - 6;
int maxY1 = tft.height() - 6;
tft.fillRect(3, 3, maxX1, 35, COLOR_BLACK);
// tft.fillRect(3,61,maxX1, maxY1 - 61, COLOR_BLACK);
if (band[bandIdx].mode == MODE_FM)
{
unit = (char *)"MHz";
bandMode = (char *)"FM";
}
else
{
unit = (char *)"KHz";
bandMode = (char *)"AM";
}
tft.setFont(&Serif_plain_7);
printValue(135, 15, oldMode, bandMode, 7, COLOR_YELLOW);
printValue(135, 36, oldUnit, unit, 7, COLOR_YELLOW);
}
/*
Prevents blinking during the frequency display.
Erases the old digits if it has changed and print the new digit values.
*/
void printValue(int col, int line, char *oldValue, char *newValue, uint8_t space, uint16_t color)
{
int c = col;
char *pOld;
char *pNew;
pOld = oldValue;
pNew = newValue;
// prints just changed digits
while (*pOld && *pNew)
{
if (*pOld != *pNew)
{
// Erases olde value
tft.setTextColor(COLOR_BLACK);
tft.setCursor(c, line);
tft.print(*pOld);
// Writes new value
tft.setTextColor(color);
tft.setCursor(c, line);
tft.print(*pNew);
}
pOld++;
pNew++;
c += space;
}
// Is there anything else to erase?
tft.setTextColor(COLOR_BLACK);
while (*pOld)
{
tft.setCursor(c, line);
tft.print(*pOld);
pOld++;
c += space;
}
// Is there anything else to print?
tft.setTextColor(color);
while (*pNew)
{
tft.setCursor(c, line);
tft.print(*pNew);
pNew++;
c += space;
}
// Save the current content to be tested next time
strcpy(oldValue, newValue);
}
/*
Shows frequency information on Display
*/
void showFrequency()
{
char freq[15];
char aux[15];
currentFrequency = rx.getFrequency();
// Serial.println(currentFrequency);
tft.setFont(&DSEG7_Classic_Mini_Regular_30);
tft.setTextSize(1);
if (band[bandIdx].mode == MODE_FM) // FM
{
sprintf(aux, "%6.6lu", currentFrequency);
freq[0] = aux[0];
freq[1] = aux[1];
freq[2] = aux[2];
freq[3] = '\0';
freq[4] = aux[3];
freq[5] = aux[4];
freq[6] = '\0';
printValue(2, 36, &oldFreq[0], &freq[0], 23, COLOR_RED);
printValue(82, 36, &oldFreq[4], &freq[4], 23, COLOR_RED);
tft.setCursor(80, 35);
tft.print('.');
}
else // AM
{
sprintf(aux, "%5lu", currentFrequency);
freq[0] = aux[0];
freq[1] = aux[1];
freq[2] = aux[2];
freq[3] = aux[3];
freq[4] = aux[4];
freq[5] = '\0';
printValue(2, 36, &oldFreq[0], &freq[0], 23, COLOR_RED);
}
}
/*
Show some basic information on display
*/
void showStatus()
{
resetBuffer();
clearStatus();
showFrequency();
showVolume();
showBandwidth();
}
/* *******************************
Shows RSSI status
*/
void showRSSI()
{
/*
char rssi[15];
// Check AM or FM
sprintf(rssi, "%3.3udBuV", (band[bandIdx].mode == MODE_FM)? rx.getFmRssi():rx.getAmRssi());
tft.setFont(&Serif_plain_14);
tft.setTextSize(1);
printValue(5, 55, oldRssi, rssi, 11, COLOR_WHITE);
*/
}
void showBandwidth()
{
char sBw[15];
if (band[bandIdx].mode != MODE_AM)
return;
sprintf(sBw, "%cKHz", am_bw[bwIdx]);
tft.setFont(&Serif_plain_14);
tft.setTextSize(1);
printValue(5, 80, oldBW, sBw, 11, COLOR_WHITE);
}
void showStereo()
{
// char stereo[10];
// sprintf(stereo, "%s", (rx.isFmStereo()) ? "St" : "Mo");
// tft.setFont(&Serif_plain_14);
// tft.setTextSize(1);
// printValue(125, 55, oldStereo, stereo, 15, COLOR_WHITE);
}
/*
Shows the volume level on LCD
*/
void showVolume()
{
// char sVolume[15];
// sprintf(sVolume, "Vol: %2.2u", rx.getVolume());
// printValue(80, 56, oldVolume, sVolume, 6, 1);
}
/*********************************************************
*********************************************************/
void showSplash()
{
// Splash
tft.setFont(&Serif_plain_14);
tft.setTextSize(1);
tft.setTextColor(COLOR_YELLOW);
tft.setCursor(45, 23);
tft.print("KT0915");
tft.setCursor(15, 50);
tft.print("Arduino Library");
tft.setCursor(25, 80);
tft.print("By PU2CLR");
tft.setFont(&Serif_plain_14);
tft.setTextSize(0);
tft.setCursor(12, 110);
tft.print("Ricardo L. Caratti");
delay(4000);
}
void bandUp()
{
// save the current frequency for the band
band[bandIdx].default_frequency = currentFrequency;
if (bandIdx < lastBand)
{
bandIdx++;
}
else
{
bandIdx = 0;
}
useBand();
}
void bandDown()
{
// save the current frequency for the band
band[bandIdx].default_frequency = currentFrequency;
if (bandIdx > 0)
{
bandIdx--;
}
else
{
bandIdx = lastBand;
}
useBand();
}
void useBand()
{
if (band[bandIdx].mode == MODE_FM)
{
rx.setFM(band[bandIdx].minimum_frequency, band[bandIdx].maximum_frequency, band[bandIdx].default_frequency, band[bandIdx].step);
rx.setDeEmphasis(DE_EMPHASIS_75);
// rx.setSoftMute(TURN_OFF);
rx.setFmAfc(TURN_ON);
rx.setMono(TURN_OFF); // Force stereo
}
else
{
rx.setAM(band[bandIdx].minimum_frequency, band[bandIdx].maximum_frequency, band[bandIdx].default_frequency, band[bandIdx].step);
rx.setAmAfc(TURN_ON);
rx.setSoftMute(TURN_OFF);
rx.setAmSpace(0); // Sets Am space channel to 1Khz.
}
delay(100);
currentFrequency = band[bandIdx].default_frequency;
rx.setFrequency(currentFrequency);
showStatus();
}
/**
* Used to test the receiver functions implemented by the library
*/
void doBandwidth()
{
if (bwIdx == 3)
bwIdx = 0;
bwIdx++;
rx.setAmBandwidth(bwIdx);
showBandwidth();
showFrequency();
delay(300);
}
void doStereo()
{
rx.setMono((bSt = !bSt));
bShow = true;
showStereo();
delay(100);
}
/**
Process seek command.
The seek direction is based on the last encoder direction rotation.
*/
void doSeek()
{
delay(200);
bShow = true;
showFrequency();
}
/*
Button - Volume control
*/
void volumeButton(byte d)
{
if (d == 1)
rx.setVolumeUp();
else
rx.setVolumeDown();
showVolume();
delay(MIN_ELAPSED_TIME); // waits a little more for releasing the button.
}
void doFilter()
{
}
void APP_loop()
{
// Check if the encoder has moved.
if (encoderCount != 0)
{
if (encoderCount == 1)
{
rx.setFrequencyUp();
}
else
{
rx.setFrequencyDown();
}
showFrequency();
bShow = true;
encoderCount = 0;
}
// Check button commands
if ((millis() - elapsedButton) > MIN_ELAPSED_TIME)
{
// check if some button is pressed
if (digitalRead(BAND_MODE_SWITCH_UP) == LOW)
bandUp();
else if (digitalRead(BAND_MODE_SWITCH_DOWN) == LOW)
bandDown();
else if (digitalRead(VOL_UP) == LOW)
volumeButton(1);
else if (digitalRead(VOL_DOWN) == LOW)
volumeButton(-1);
else if (digitalRead(SWITCH_BW) == LOW)
doBandwidth();
}
if ((millis() - pollin_elapsed) > POLLING_TIME)
{
showRSSI();
pollin_elapsed = millis();
}
delay(100);
}

View File

116
Core/App/Graphic/ui.c Normal file
View File

@ -0,0 +1,116 @@
#include <stdint.h>
#include "global.h"
#include "st7735.h"
#include "Images/digi18x32.h"
#include "monoimg.h"
#include "bmfont.h"
#include "asciifont.h"
void ui_text_number18x32(uint32_t num, uint16_t x, uint16_t y, uint16_t color) {
uint32_t tmp = num;
uint32_t div = 1;
uint8_t num_count = 0;
while (tmp > 0) {
tmp = tmp / 10;
num_count ++;
div = div * 10;
}
div = div / 10;
if (div == 0) {
mimg_Area area = mimg_get_tile_area(IMG_DIGI_18_32, 10, 1, 0);
mimg_draw(ST7735_DrawPixel, x, y, color, IMG_DIGI_18_32, area);
} else {
while (div > 0) {
tmp = (num / div) % 10;
mimg_Area area = mimg_get_tile_area(IMG_DIGI_18_32, 10, 1, tmp);
mimg_draw(ST7735_DrawPixel, x, y, color, IMG_DIGI_18_32, area);
x = x + 18;
div = div / 10;
}
}
}
// TODO: 绘制界面的函数
/* UI元素 */
void ui_com_main_border() {
// border
ST7735_FillRectangle(0, 0, ST7735_WIDTH, 1, ST7735_YELLOW);
ST7735_FillRectangle(0, 17, ST7735_WIDTH, 1, ST7735_YELLOW);
ST7735_FillRectangle(0, ST7735_HEIGHT - 34, ST7735_WIDTH, 1, ST7735_YELLOW);
ST7735_FillRectangle(0, ST7735_HEIGHT - 1, ST7735_WIDTH, 1, ST7735_YELLOW);
ST7735_FillRectangle(0, 0, 1, ST7735_HEIGHT, ST7735_YELLOW);
ST7735_FillRectangle(ST7735_WIDTH - 1, 0, 1, ST7735_HEIGHT, ST7735_YELLOW);
}
void ui_com_freq_digital(uint8_t clear) {
// 5位数字, 即高32宽90
uint16_t off_x = (ST7735_WIDTH - 90) / 2;
uint16_t off_y = (ST7735_HEIGHT - 32 - 34 - 18) / 2 + 17;
if (clear) {
ST7735_FillRectangle(off_x, off_y, 32, 90, ST7735_BLACK);
}
uint16_t scale = 10000;
uint32_t tmp = 0;
while (scale > 0) {
tmp = (global_data.freq / scale) % 10;
ui_text_number18x32(tmp, off_x, off_y, ST7735_COLOR565(0xFF, 0x7F, 0));
off_x += 18;
scale /= 10;
}
}
void ui_com_progress_bar(uint8_t clear, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t border_color, uint16_t fill_color, uint32_t current, uint32_t total) {
if (clear) {
ST7735_FillRectangle(x, y, w, h, ST7735_BLACK);
}
// border
ST7735_FillRectangle(x, y, w, 1, border_color);
ST7735_FillRectangle(x, y + h - 1, w, 1, border_color);
ST7735_FillRectangle(x, y, 1, h, border_color);
ST7735_FillRectangle(x + w - 1, y, 1, h, border_color);
// bar
x += 1;
y += 1;
w -= 2;
h -= 2;
uint16_t bar_width = w * current / total;
ST7735_FillRectangle(x, y, bar_width, h, fill_color);
}
void ui_com_vol_bar(uint8_t clear) {
uint16_t off_x = 1;
uint16_t off_y = ST7735_HEIGHT - 33;
if (clear) {
ST7735_FillRectangle(off_x, off_y, ST7735_WIDTH - 2, 16, ST7735_BLACK);
}
uint16_t color_skyblue = ST7735_COLOR565(0, 0x7F, 0xFF);
// text, 32x16
off_x = off_x + (32 - bmf_get_text_width(font_unifont_16x16, u8str("VOL"), 3)) / 2;
bmf_draw_text(font_unifont_16x16, u8str("VOL"), 3, off_x, off_y, 32, 16, color_skyblue);
// bar
off_x = 1 + 32;
ui_com_progress_bar(clear, 33, off_y + 2, ST7735_WIDTH - 34 - 3, 13, ST7735_WHITE, color_skyblue, global_data.volumn, 16);
}
void ui_com_sig_bar(uint8_t clear) {
uint16_t off_x = 1;
uint16_t off_y = ST7735_HEIGHT - 17;
if (clear) {
ST7735_FillRectangle(off_x, off_y, ST7735_WIDTH - 2, 16, ST7735_BLACK);
}
// text, 32x16
off_x = off_x + (32 - bmf_get_text_width(font_unifont_16x16, u8str("SIG"), 3)) / 2;
bmf_draw_text(font_unifont_16x16, u8str("SIG"), 3, off_x, off_y, 32, 16, ST7735_GREEN);
// bar
off_x = 1 + 32;
ui_com_progress_bar(clear, 33, off_y + 1, ST7735_WIDTH - 34 - 3, 13, ST7735_WHITE, ST7735_GREEN, global_data.signal, 255);
}
/* 供外部调用的方法 */
void ui_screen_main() {
ST7735_FillScreen(ST7735_BLACK);
ui_com_main_border();
ui_com_freq_digital(0);
ui_com_vol_bar(0);
ui_com_sig_bar(0);
}

View File

@ -2,3 +2,6 @@
#include <stdint.h>
void ui_text_number18x32(uint32_t num, uint16_t x, uint16_t y, uint16_t color);
/* 绘制主界面 */
void ui_screen_main();

11
Core/App/app.c Normal file
View File

@ -0,0 +1,11 @@
#include "gpio.h"
#include "ui.h"
void app_init() {
ui_screen_main();
}
void app_main_loop() {
HAL_GPIO_TogglePin(LED_STATUS_GPIO_Port,LED_STATUS_Pin);
HAL_Delay(300);
}

4
Core/App/app.h Normal file
View File

@ -0,0 +1,4 @@
#pragma once
void app_init();
void app_main_loop();

9
Core/App/global.c Normal file
View File

@ -0,0 +1,9 @@
#include <stdint.h>
#include "global.h"
GlobalData global_data = {
901, // freq
0, // freq_float
16, // volumn
97 //signal
};

12
Core/App/global.h Normal file
View File

@ -0,0 +1,12 @@
/** Global Data Define */
#pragma once
#include <stdint.h>
typedef struct GlobalData {
uint32_t freq;
uint8_t freq_float;
uint8_t volumn;
uint8_t signal;
} GlobalData;
extern GlobalData global_data;

View File

@ -1,5 +1,5 @@
// Rotary encoder library for Arduino.
#include "main.h"
#include "hardware.h"
#include "tim.h"
#ifndef rotary_h

View File

@ -1,4 +1,7 @@
/* vim: set ai et ts=4 sw=4: */
#include <stdint.h>
#include "gpio.h"
#include "spi.h"
#include "st7735.h"
#define DELAY 0x80
@ -148,9 +151,6 @@ static void ST7735_SetAddressWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t
data[1] = y0 + ST7735_YSTART;
data[3] = y1 + ST7735_YSTART;
ST7735_WriteData(data, sizeof(data));
// write to RAM
ST7735_WriteCommand(ST7735_RAMWR);
}
void ST7735_Init()
@ -171,6 +171,7 @@ void ST7735_DrawPixel(uint16_t x, uint16_t y, uint16_t color) //画点
ST7735_Select();
ST7735_SetAddressWindow(x, y, x + 1, y + 1);
ST7735_WriteCommand(ST7735_RAMWR);
uint8_t data[] = {color >> 8, color & 0xFF};
ST7735_WriteData(data, sizeof(data));
@ -240,6 +241,7 @@ void ST7735_FillRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16
ST7735_Select();
ST7735_SetAddressWindow(x, y, x + w - 1, y + h - 1);
ST7735_WriteCommand(ST7735_RAMWR);
uint8_t data[] = {color >> 8, color & 0xFF};
HAL_GPIO_WritePin(ST7735_DC_GPIO_Port, ST7735_DC_Pin, GPIO_PIN_SET);
@ -271,6 +273,7 @@ void ST7735_DrawImage(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint
ST7735_Select();
ST7735_SetAddressWindow(x, y, x + w - 1, y + h - 1);
ST7735_WriteCommand(ST7735_RAMWR);
ST7735_WriteData((uint8_t *)data, sizeof(uint16_t) * w * h);
ST7735_Unselect();
}

View File

@ -3,8 +3,10 @@
#define __ST7735_H__
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "main.h"
#include "hardware.h"
#include "spi.h"
#define ST7735_MADCTL_MY 0x80
#define ST7735_MADCTL_MX 0x40

View File

@ -2,7 +2,7 @@
#define __I2C_SW_H
/* includes */
#include "main.h"
#include "hardware.h"
#include "stdio.h"
/* defines */

View File

@ -18,7 +18,7 @@
/* #include <Arduino.h>
#include <Wire.h> */
#include "main.h"
#include "hardware.h"
#include "i2c_sw.h"
#define KT0915_I2C_ADDRESS 0x6A //arduino:0x35 It is needed to check it when the KT0915 device arrives.

40
Core/Inc/hardware.h Normal file
View File

@ -0,0 +1,40 @@
#include "stm32g0xx_hal.h"
#define ENCODER_KEY_Pin GPIO_PIN_13
#define ENCODER_KEY_GPIO_Port GPIOC
#define KEY_1_Pin GPIO_PIN_0
#define KEY_1_GPIO_Port GPIOA
#define KEY_2_Pin GPIO_PIN_1
#define KEY_2_GPIO_Port GPIOA
#define KEY_3_Pin GPIO_PIN_2
#define KEY_3_GPIO_Port GPIOA
#define KEY_4_Pin GPIO_PIN_3
#define KEY_4_GPIO_Port GPIOA
#define KEY_5_Pin GPIO_PIN_4
#define KEY_5_GPIO_Port GPIOA
#define LCD_BK_Pin GPIO_PIN_6
#define LCD_BK_GPIO_Port GPIOA
#define LED_2_Pin GPIO_PIN_8
#define LED_2_GPIO_Port GPIOA
#define ENCODER_A_Pin GPIO_PIN_6
#define ENCODER_A_GPIO_Port GPIOC
#define ENCODER_B_Pin GPIO_PIN_7
#define ENCODER_B_GPIO_Port GPIOC
#define LED_3_Pin GPIO_PIN_11
#define LED_3_GPIO_Port GPIOA
#define LED_4_Pin GPIO_PIN_12
#define LED_4_GPIO_Port GPIOA
#define LED_STATUS_Pin GPIO_PIN_15
#define LED_STATUS_GPIO_Port GPIOA
#define LCD_RST_Pin GPIO_PIN_0
#define LCD_RST_GPIO_Port GPIOD
#define KEY_6_Pin GPIO_PIN_1
#define KEY_6_GPIO_Port GPIOD
#define LCD_DC_Pin GPIO_PIN_2
#define LCD_DC_GPIO_Port GPIOD
#define LED_1_Pin GPIO_PIN_3
#define LED_1_GPIO_Port GPIOD
#define SWI2C_SCL_Pin GPIO_PIN_3
#define SWI2C_SCL_GPIO_Port GPIOB
#define SWI2C_SDA_Pin GPIO_PIN_4
#define SWI2C_SDA_GPIO_Port GPIOB

View File

@ -31,6 +31,7 @@ extern "C" {
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "hardware.h"
/* USER CODE END Includes */
@ -57,44 +58,6 @@ void Error_Handler(void);
/* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/
#define ENCODER_KEY_Pin GPIO_PIN_13
#define ENCODER_KEY_GPIO_Port GPIOC
#define KEY_1_Pin GPIO_PIN_0
#define KEY_1_GPIO_Port GPIOA
#define KEY_2_Pin GPIO_PIN_1
#define KEY_2_GPIO_Port GPIOA
#define KEY_3_Pin GPIO_PIN_2
#define KEY_3_GPIO_Port GPIOA
#define KEY_4_Pin GPIO_PIN_3
#define KEY_4_GPIO_Port GPIOA
#define KEY_5_Pin GPIO_PIN_4
#define KEY_5_GPIO_Port GPIOA
#define LCD_BK_Pin GPIO_PIN_6
#define LCD_BK_GPIO_Port GPIOA
#define LED_2_Pin GPIO_PIN_8
#define LED_2_GPIO_Port GPIOA
#define ENCODER_A_Pin GPIO_PIN_6
#define ENCODER_A_GPIO_Port GPIOC
#define ENCODER_B_Pin GPIO_PIN_7
#define ENCODER_B_GPIO_Port GPIOC
#define LED_3_Pin GPIO_PIN_11
#define LED_3_GPIO_Port GPIOA
#define LED_4_Pin GPIO_PIN_12
#define LED_4_GPIO_Port GPIOA
#define LED_STATUS_Pin GPIO_PIN_15
#define LED_STATUS_GPIO_Port GPIOA
#define LCD_RST_Pin GPIO_PIN_0
#define LCD_RST_GPIO_Port GPIOD
#define KEY_6_Pin GPIO_PIN_1
#define KEY_6_GPIO_Port GPIOD
#define LCD_DC_Pin GPIO_PIN_2
#define LCD_DC_GPIO_Port GPIOD
#define LED_1_Pin GPIO_PIN_3
#define LED_1_GPIO_Port GPIOD
#define SWI2C_SCL_Pin GPIO_PIN_3
#define SWI2C_SCL_GPIO_Port GPIOB
#define SWI2C_SDA_Pin GPIO_PIN_4
#define SWI2C_SDA_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */

View File

@ -1,25 +0,0 @@
#include <stdint.h>
#include "Images/digi18x32.h"
#include "monoimg.h"
#include "st7735.h"
void ui_text_number18x32(uint32_t num, uint16_t x, uint16_t y, uint16_t color) {
uint32_t tmp = num;
uint32_t div = 1;
uint8_t num_count = 0;
while (tmp > 0) {
tmp = tmp / 10;
num_count ++;
div = div * 10;
}
div = div / 10;
while (div > 0) {
tmp = (num / div) % 10;
mimg_Area area = mimg_get_tile_area(IMG_DIGI_18_32, 10, 1, tmp);
mimg_draw(ST7735_DrawPixel, x, y, color, IMG_DIGI_18_32, area);
x = x + 18;
div = div / 10;
}
}
// TODO: 绘制文字的方法

View File

@ -26,11 +26,8 @@
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdio.h>
#include "RotaryCoder.h"
#include "st7735.h"
#include "ui.h"
#include "bmfont.h"
#include "asciifont.h"
#include "app.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@ -71,8 +68,6 @@ void LCD_init()
{
ST7735_Init(); // 屏幕初始化
HAL_GPIO_WritePin(LCD_BK_GPIO_Port, LCD_BK_Pin, GPIO_PIN_SET);
//const char ready[] = "Init Ready!\r\n";
//HAL_UART_Transmit(&huart1, (uint8_t *)ready, sizeof(ready) - 1, HAL_MAX_DELAY);
}
/* USER CODE END 0 */
@ -108,16 +103,8 @@ int main(void)
MX_SPI1_Init();
MX_TIM3_Init();
/* USER CODE BEGIN 2 */
/*EC11_init();
uint16_t Count;
uint16_t Diretion;*/
printf("program start\n");
LCD_init();
ST7735_FillScreen(ST7735_WHITE);
printf("Begin draw number\n");
ui_text_number18x32(10086, 0, 0, ST7735_BLUE);
bmf_draw_text(font_unifont_16x16, u8str("Test Ascii\nHello Dragon Ok~~~~"), 29, 0, 40, 160, 64, ST7735_BLACK);
printf("End draw number\n");
app_init();
/* USER CODE END 2 */
/* Infinite loop */
@ -126,16 +113,7 @@ int main(void)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_GPIO_TogglePin(LED_STATUS_GPIO_Port,LED_STATUS_Pin);
HAL_Delay(300);
/*
Count = EC11_COUNT();
Diretion = EC11_DIR();
printf("DIRE:%d COUNT:%d \r\n",Diretion,Count);
HAL_Delay(500);
*/
app_main_loop();
}
/* USER CODE END 3 */
}

View File

@ -39,7 +39,8 @@ void MX_SPI1_Init(void)
/* USER CODE END SPI1_Init 1 */
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
// hspi1.Init.Direction = SPI_DIRECTION_2LINES;
hspi1.Init.Direction = SPI_DIRECTION_1LINE;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;