ee
This commit is contained in:
parent
4ef67c751e
commit
77c50e6a36
@ -18,7 +18,18 @@
|
||||
/* USER CODE END Header */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
#include "stm32f0xx_ll_adc.h"
|
||||
#include "stm32f0xx_ll_dma.h"
|
||||
#include "stm32f0xx_ll_crs.h"
|
||||
#include "stm32f0xx_ll_rcc.h"
|
||||
#include "stm32f0xx_ll_bus.h"
|
||||
#include "stm32f0xx_ll_system.h"
|
||||
#include "stm32f0xx_ll_exti.h"
|
||||
#include "stm32f0xx_ll_cortex.h"
|
||||
#include "stm32f0xx_ll_utils.h"
|
||||
#include "stm32f0xx_ll_pwr.h"
|
||||
#include "stm32f0xx_ll_spi.h"
|
||||
#include "stm32f0xx_ll_gpio.h"
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "../lvgl/lvgl.h"
|
||||
|
13026
MDK-ARM/JLinkLog.txt
13026
MDK-ARM/JLinkLog.txt
File diff suppressed because it is too large
Load Diff
@ -7,10 +7,14 @@
|
||||
#include "../ili9341/lv_driver.h"
|
||||
#include "lv_conf.h"
|
||||
|
||||
short gPosx,gPosy;
|
||||
lv_indev_t * indev_touchpad; // ?????????
|
||||
lv_obj_t* kb;
|
||||
|
||||
short ReadX(){
|
||||
static short average[5] = {0};
|
||||
static short average[2] = {0};
|
||||
static unsigned char pos = 0;
|
||||
short ret = 0;
|
||||
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_0;
|
||||
@ -36,23 +40,31 @@ short ReadX(){
|
||||
LL_GPIO_SetOutputPin(GPIOB, LL_GPIO_PIN_1);
|
||||
|
||||
LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_1);
|
||||
LL_mDelay(100);
|
||||
LL_mDelay(1);
|
||||
ADC1->CHSELR = LL_ADC_CHANNEL_8;
|
||||
ADC1->IER = 0;
|
||||
ADC1->CR |= ADC_CR_ADSTART;
|
||||
|
||||
while (ADC1->CR & ADC_CR_ADSTART)
|
||||
;
|
||||
average[pos] = LL_ADC_REG_ReadConversionData32(ADC1);
|
||||
pos++;
|
||||
if (pos > 5) pos= 0;
|
||||
return (average[0] + average[1] + average[2] + average[3] + average[5])/3;
|
||||
|
||||
if( LL_ADC_REG_ReadConversionData32(ADC1) < 500){
|
||||
gPosy = -1;
|
||||
return -1;
|
||||
}
|
||||
float s = (float)( LL_ADC_REG_ReadConversionData32(ADC1) -600)/11.65;
|
||||
ret = s;
|
||||
{
|
||||
gPosy = ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
short ReadY(){
|
||||
static short average[3] = {0};
|
||||
static unsigned char pos = 0;
|
||||
short ret = 0;
|
||||
|
||||
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
@ -79,17 +91,68 @@ short ReadY(){
|
||||
LL_GPIO_SetOutputPin(GPIOB, LL_GPIO_PIN_0);
|
||||
|
||||
LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_0);
|
||||
LL_mDelay(100);
|
||||
LL_mDelay(1);
|
||||
ADC1->CHSELR = LL_ADC_CHANNEL_9;
|
||||
ADC1->IER = 0;
|
||||
ADC1->CR |= ADC_CR_ADSTART;
|
||||
|
||||
while (ADC1->CR & ADC_CR_ADSTART)
|
||||
;
|
||||
average[pos] = LL_ADC_REG_ReadConversionData32(ADC1);
|
||||
pos++;
|
||||
if (pos > 2) pos= 0;
|
||||
return (average[0] + average[1] + average[2])/3;
|
||||
|
||||
ret = LL_ADC_REG_ReadConversionData32(ADC1);
|
||||
if(ret < 500) {
|
||||
gPosx = -1;
|
||||
return -1;
|
||||
}
|
||||
float tmp = (float)(3560 - ret)/9.3;
|
||||
ret = (short)tmp;
|
||||
if(ret < 0)
|
||||
return 0;
|
||||
else {
|
||||
gPosx = ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static bool touchpad_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data)
|
||||
{
|
||||
static lv_coord_t last_x = 0;
|
||||
static lv_coord_t last_y = 0;
|
||||
|
||||
|
||||
if( (gPosy > 0 )&&(gPosx > 0)) {
|
||||
last_x = gPosx;
|
||||
last_y = gPosy;
|
||||
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
}
|
||||
else
|
||||
{
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void ta_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * ta = lv_event_get_target(e);
|
||||
lv_obj_t * kb = lv_event_get_user_data(e);
|
||||
if(code == LV_EVENT_FOCUSED) {
|
||||
lv_keyboard_set_textarea(kb, ta);
|
||||
lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
if(code == LV_EVENT_DEFOCUSED) {
|
||||
lv_keyboard_set_textarea(kb, NULL);
|
||||
lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -150,41 +213,67 @@ int main(void)
|
||||
disp_drv.ver_res = 240; /*Set the vertical resolution in pixels*/
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
LL_mDelay(100);
|
||||
lv_obj_t *src = lv_scr_act();//??????
|
||||
|
||||
lv_obj_t *label1 = lv_label_create(src);//????
|
||||
lv_obj_t *label2 = lv_label_create(src);//????
|
||||
|
||||
//LV_LABEL_LONG_EXPAND ??,?????????
|
||||
lv_obj_set_pos(label1,20,20);//????
|
||||
lv_obj_set_size(label1,100,50);//?????
|
||||
lv_indev_drv_t indev_drv;
|
||||
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read_cb = touchpad_read;
|
||||
indev_touchpad = lv_indev_drv_register(&indev_drv);
|
||||
|
||||
lv_obj_t *src = lv_scr_act();
|
||||
|
||||
lv_obj_t *label1 = lv_label_create(src);
|
||||
lv_obj_t *label2 = lv_label_create(src);
|
||||
|
||||
//LV_LABEL_LONG_EXPAND
|
||||
lv_obj_set_pos(label1,120,20);
|
||||
lv_obj_set_size(label1,100,50);
|
||||
sprintf(tmp,"x:%d", ReadX());
|
||||
lv_label_set_text(label1,tmp);//??????
|
||||
lv_label_set_text(label1,tmp);
|
||||
//lv_obj_set_style_bg_color(lv_scr_act(), lv_palette_lighten(LV_PALETTE_GREY, 4), 0);
|
||||
|
||||
lv_obj_set_pos(label2,20,50);//????
|
||||
lv_obj_set_size(label2,100,50);//?????
|
||||
lv_obj_set_pos(label2,120,50);
|
||||
lv_obj_set_size(label2,100,50);
|
||||
sprintf(tmp,"y:%d", ReadY());
|
||||
lv_label_set_text(label2,tmp);//??????
|
||||
//lv_obj_t* kb = lv_keyboard_create(lv_scr_act());
|
||||
//lv_obj_set_align(kb, LV_ALIGN_CENTER);
|
||||
//lv_obj_set_size(kb, 300, 150);
|
||||
lv_label_set_text(label2,tmp);
|
||||
|
||||
lv_obj_t *label = lv_label_create(lv_scr_act());
|
||||
lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0x000000), 0); //0x000000 = ??
|
||||
lv_label_set_recolor(label, true); //??????
|
||||
lv_obj_set_pos(label, 10, 10); //????
|
||||
lv_obj_set_size(label, 80, 60); //?????
|
||||
LV_FONT_DECLARE(lv_font_montserrat_20) //????
|
||||
lv_label_set_text(label, "#00ff80 freq:#"); //????
|
||||
lv_obj_set_style_text_font(label, &lv_font_montserrat_20, 0);
|
||||
|
||||
kb = lv_keyboard_create(lv_scr_act());
|
||||
lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_NUMBER);
|
||||
lv_obj_t * ta;
|
||||
ta = lv_textarea_create(lv_scr_act());
|
||||
lv_obj_add_event_cb(ta, ta_event_cb, LV_EVENT_ALL, kb);
|
||||
lv_obj_set_pos(ta, 90, 10); //????
|
||||
lv_textarea_set_placeholder_text(ta, "10000000");
|
||||
lv_obj_set_size(ta, 200, 60);
|
||||
static lv_style_t style;
|
||||
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
while (1)
|
||||
{
|
||||
LL_mDelay(5);
|
||||
LL_mDelay(1);
|
||||
/* USER CODE END WHILE */
|
||||
lv_task_handler();
|
||||
lv_tick_inc(10);
|
||||
ReadX();
|
||||
ReadY();
|
||||
|
||||
sprintf(tmp,"x:%d", ReadX());
|
||||
lv_label_set_text(label1,tmp);//??????
|
||||
LL_mDelay(1);
|
||||
|
||||
sprintf(tmp,"y:%d", ReadY());
|
||||
lv_label_set_text(label2,tmp);//??????
|
||||
//sprintf(tmp,"y:%d", ReadX());
|
||||
//lv_label_set_text(label1,tmp);//??????
|
||||
//LL_mDelay(1);
|
||||
//sprintf(tmp,"x:%d", ReadY());
|
||||
//lv_label_set_text(label2,tmp);//??????
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
}
|
||||
|
@ -363,10 +363,10 @@
|
||||
#define LV_FONT_MONTSERRAT_8 0
|
||||
#define LV_FONT_MONTSERRAT_10 0
|
||||
#define LV_FONT_MONTSERRAT_12 0
|
||||
#define LV_FONT_MONTSERRAT_14 1
|
||||
#define LV_FONT_MONTSERRAT_14 0
|
||||
#define LV_FONT_MONTSERRAT_16 0
|
||||
#define LV_FONT_MONTSERRAT_18 0
|
||||
#define LV_FONT_MONTSERRAT_20 0
|
||||
#define LV_FONT_MONTSERRAT_20 1
|
||||
#define LV_FONT_MONTSERRAT_22 0
|
||||
#define LV_FONT_MONTSERRAT_24 0
|
||||
#define LV_FONT_MONTSERRAT_26 0
|
||||
@ -398,7 +398,7 @@
|
||||
#define LV_FONT_CUSTOM_DECLARE
|
||||
|
||||
/*Always set a default font*/
|
||||
#define LV_FONT_DEFAULT &lv_font_montserrat_14
|
||||
#define LV_FONT_DEFAULT &lv_font_montserrat_20
|
||||
|
||||
/*Enable handling large font and/or fonts with a lot of characters.
|
||||
*The limit depends on the font size, font face and bpp.
|
||||
|
@ -1205,7 +1205,7 @@
|
||||
#ifdef CONFIG_LV_FONT_DEFAULT
|
||||
#define LV_FONT_DEFAULT CONFIG_LV_FONT_DEFAULT
|
||||
#else
|
||||
#define LV_FONT_DEFAULT &lv_font_montserrat_14
|
||||
#define LV_FONT_DEFAULT &lv_font_montserrat_20
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user