This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] EK-TM4C123GXL:请提供按钮小工具帮助

Guru**** 2330830 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/593245/ek-tm4c123gxl-pushbutton-widget-help-please

器件型号:EK-TM4C123GXL

我正在使用 Kentec Booster Pack 并尝试制作一些屏幕。  我有一个显示2个模拟值的工作屏幕、然后有一个启动/停止按钮、该按钮将启用电机。

现在、我尝试将所有这些代码移动到 screen_1、以便我可以开始创建多个屏幕。  我已使 ADC 读数正常工作、但我似乎无法使按钮小工具正常工作。  我整天都在不同的位置播放代码的不同部分、但我无法在屏幕上弹出按钮、更不用说它的功能了。  之前我在 widget_root 上有按钮、但该按钮不起作用、因此我将其移至 Canvas (我认为...)。  是否有人能在下面看到我做错的明显事情?

main.c

//
// 声明头文件
#include 
#include 
#include "grlib/grlib.h"
#include "grlib/widget.h"
#include "grlib/canvas.h"
#include "grlib/button.h"
#include "initialize.h"
#include "touch


// 声明/初始化变量
bool start_stop = false;
bool allow_run=false;

//*********

int main (void)
{
//将系统时钟初始化为80MHz
SysCtlClockSet (SYSCTL_SYSDIV_2|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHz|SYSCTL_OSC_MAIN);

Kentec320x240x16_SSD2119Init(); //屏幕初始化

initialize(); //初始化例程

//初始化触摸屏并添加小工具
TouchScreenInit(); //初始化触摸屏

//启用所有中断
IntMasterEnable();

//开始表演的时间!
TimerEnable (TIMER2_base、timer_both); //启用 Timer2以更新屏幕
TimerEnable (Timer1_base、timer_both); //启用 Timer1以获取样本读数

//输入无限循环并让中断处理除触摸屏按钮之外的所有内容
while (1)
{

//WidgetMessageQueueProcedure(); //Extract and Process widget messages 1 at a
time }(一次提取并处理 widget 消息1)
}

从我的初始化例程:

//初始化工程图上下文并准备使用
GrContextInit (&sContext、&g_sKentec320x240x16_SSD2119);
ClrScreen(); //清除屏幕
GrContextFontSet (&sContext、&g_sFontCms30b); //设置字体 

Screen_update 头:

#include 
#include 
#include 
#include "grlib/grlib.h"
#include "driverlib/timer.h"
#include "inc/hw_memmap.h"
#include "grlib/widget.h"
#include "grlib/canvas.h"
#include "grlib/kent.h"
#include "explec320x240x16_ssd2119_8bit.h



;
extern context tintrush_t;include "exit_trushit_intration.n";exit_trushit_int intration.cn;include "exit_trushit_trush"#include "exit_intn_intn_intn_intn_intn_intn_int_int_int_int_



extern tRectangle sRect;
extern tPushButtonWidget g_sPushBtn;
extern tCanvasg_sBackground;

#ifndef _screen update_H_
#define _screen update_H_

//声明屏幕功能
void screen_update (void);
void screen_1 (

Widget);void screen_1_changes (void
);void 屏幕截图(void);void (void)

//声明屏幕中使用的变量
uint32_t screen_curry=0;
uint32_t screen_call=1;
char ref_buf[5];
char sample_buf[5];
tRectangle sRect_CLR;

//为 Button
Canvas 制作画布(g_sBackground、widget_root、0、&g_sPushBtn、
&g_sKentec320x240x16_SSD2119、199、125、45、
canva_style_fill、ClrBlack、0、0、0、 0、0、0);

//开始/停止
矩形按钮(g_sPushBtn、&g_sBackground、0、0、0、
&g_sKentec320x240x16_SSD2119、200、200、120、40、
(PB_style_outline | PB_style_text_op不透明| PB_style_text |
PB_style_fill)、ClrGray、ClrWhite、ClrRed、ClrRed、
G_psFontCmss22b、"开始/停止"、0、0、0、0、 0、OnButtonPress);

#endif

Screen_update 源:

#include "screen_update.h"

void screen_update (void){

//清除计时器中断
TimerIntClear (TIMER2_base、TIMER_TINA_TIMEOUT);

//如果我们不在请求的同一屏幕中,则调用该基本屏幕
if (screen_called!=screen_current){
Screen_1 ();
Screen_Current=1;
}
//如果我们仍在请求的当前屏幕中,则更新该屏幕中的数据
其他
{
Screen_1_changes();

}
}

//base screen 1
void screen_1 (void){


//设置回调,添加小部件,绘制小部件
TouchScreenCallbackSet (WidgetPointerMessage);
WidgetAdd (widget_root、(tWidget *)&g_sBackground); //向小部件添加按钮
WidgetPaint (widget_root); //在屏幕上绘制小工具

//为屏幕1中的参数定义清晰的矩形
sRect_CLR.i16XMin = 145;
sRect_CLR.i16YMin = 2;
sRect_CLR.i16XMax = 260;
sRect_CLR.i16YMax = 80;

//打印数据标签
GrContextForegroundSet (&sContext、ClrGray); //将文本更改为灰色
GrStringDraw (&S Context、"Reference:"、-1、2、2、 0); //打印出参考:标签
GrStringDraw (&S Context、"速度:"、-1、2、40、 0); //打印速度:标签

//将缓冲区刷新到屏幕
GrFlush (&sContext);
}

//screen 1更新
void screen_1_changes (void){

GrContextForegroundSet (&sContext、ClrBlack);
GrRectFill (&sContext、&sRect_CLR);
格林图(&S);


//从网站: stackoverflow.com/.../how-to-convert-uint64-t-value-in-const-char-string
snprintf (ref_buf、5、"%"PRIu32、参考); //将整数 ADC 值转换为 const char*
snprintf (sample_buf、5、"%"PRIu32、反馈); //将整数 ADC 值转换为 const char*

//在屏幕上写入新显示的值
GrContextForegroundSet (&sContext、ClrBlue);
GrStringDraw (&S) Context、ref_Buf、5、150、2、 0);
GrStringDraw (&S Context、sample_buf、5、150、40、 0);
GrFlush (&sContext);

}

//Clear screen 函数
void ClrScreen()
{
sRect.i16XMin = 0;
sRect.i16YMin = 0;
sRect.i16XMax = 319;
sRect.i16YMax = 239;
GrContextForegroundSet (&sContext、ClrBlack);
GrRectFill (&sContext、&sRect);
GrFlush (&sContext);
}

//function for button press
void OnButtonPress (tWidget * pWidget)
{
start_stop =!start_stop;
if (启动/停止)
{
//GPIOPinWrite (GPIO_PORTC_BASE、GPIO_PIN_6、0x40);
allow_run=true;
}
其他
{
//GPIOPinWrite (GPIO_PORTC_BASE、GPIO_PIN_6、0x00);
allow_run=false;
}
}

 

 

 

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您好、Shane、

    我希望这篇文章能为您提供一些线索。 我也不熟悉图形库。

    e2e.ti.com/.../1644867
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    谢谢 Charles。 这是一个很好的线程。 我目前正在复制并粘贴'grlib_demo.c'代码的一部分、并对其执行的操作进行解剖。 正在取得进展、但还有很多需要学习的东西。

    看起来、此图形库能够满足我的所有需求、但我始终喜欢学习基础知识。 您知道 Stellaris 图形库是否与其它图形库相似吗? 例如、其他图形库是否执行画布、容器、按钮类型等操作?