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.
我从 TivaLaunchpad 成功获得写入 Kentec BoosterPack 显示屏的字符。 但是、当我写入的值下降一个数量级时、我将得到一个持续的数字。 例如、我将写入1546、但没关系。 但是、如果该值变为63、则屏幕上读取的值为:6346 、因为它没有覆盖1546数字的"46"部分。 我尝试将"%"更改为"%+"、但它不起作用、我收到错误。
如果您更清楚地了解我在写入新值之前应该如何清除我的值、请提出建议。 但是、我仍需要正确调整新值、以便1的位置始终在显示的值中对齐。 无论前置零件是否为空白或0、目前对我来说都没有太大的影响。
作为次要后续步骤: 我最终将不得不写入十进制值、而我转换的方式仅适用于整数。 如果您可以建议一种将整数写入屏幕的方法、那将非常好。 或者、如果您能向我指出一个同样精彩的资源。
下面是我当前写入屏幕的方式:
#include #include extern uint32_t 引用; extern tContext sContext; extern tRectangle sRect; char ref_buf[5]; char sample_buf[5]; void screen_update (void){ TimerIntClear (TIMER5_base、TIMER_TINA_TIMEOUT); //从网站: 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、VelocityFB); //将整数 ADC 值转换为 const char* //用黑色书写,清除最后显示的值 GrContextForegroundSet (&sContext、ClrBlack); GrStringDraw (&S) Context、ref_Buf、6、150、2、 1); GrStringDraw (&S Context、sample_buf、6、150、40、 1); //在屏幕上写入新显示的值 GrContextForegroundSet (&sContext、ClrRed); GrStringDraw (&S) Context、ref_Buf、5、150、2、 0); GrStringDraw (&S Context、sample_buf、5、150、40、 0); GrFlush (sContext); }