fix(sprintf) add format string for rp2 port (#2512)
* fixes for rp2 port (only format strings: int/int32_t mismatch, %d -> %ld) * use portable PRId32 printf format, #include <inttypes.h> via lv_printf.h * define LV_PRId32 macro (for int) * figure out good way to build inside Micropython (plus indentation) * re-add examples (lost on the way) * hopefully fix PRI32d * Revert off CMakeLists.txt changes so that this is about printf only
This commit is contained in:
@@ -1406,7 +1406,7 @@ static void draw_y_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
|||||||
/*add text only to major tick*/
|
/*add text only to major tick*/
|
||||||
if(major && t->label_en) {
|
if(major && t->label_en) {
|
||||||
char buf[16];
|
char buf[16];
|
||||||
lv_snprintf(buf, sizeof(buf), "%d", tick_value);
|
lv_snprintf(buf, sizeof(buf), "%" LV_PRId32, tick_value);
|
||||||
part_draw_dsc.label_dsc = &label_dsc;
|
part_draw_dsc.label_dsc = &label_dsc;
|
||||||
part_draw_dsc.text = buf;
|
part_draw_dsc.text = buf;
|
||||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||||
@@ -1537,7 +1537,7 @@ static void draw_x_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
|||||||
|
|
||||||
if(major && t->label_en) {
|
if(major && t->label_en) {
|
||||||
char buf[16];
|
char buf[16];
|
||||||
lv_snprintf(buf, sizeof(buf), "%d", tick_value);
|
lv_snprintf(buf, sizeof(buf), "%" LV_PRId32, tick_value);
|
||||||
part_draw_dsc.label_dsc = &label_dsc;
|
part_draw_dsc.label_dsc = &label_dsc;
|
||||||
part_draw_dsc.text = buf;
|
part_draw_dsc.text = buf;
|
||||||
|
|
||||||
|
|||||||
@@ -497,7 +497,7 @@ static void draw_ticks_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
|
|||||||
part_draw_dsc.label_dsc = &label_dsc_tmp;
|
part_draw_dsc.label_dsc = &label_dsc_tmp;
|
||||||
char buf[16];
|
char buf[16];
|
||||||
|
|
||||||
lv_snprintf(buf, sizeof(buf), "%d", value_of_line);
|
lv_snprintf(buf, sizeof(buf), "%" LV_PRId32, value_of_line);
|
||||||
part_draw_dsc.text = buf;
|
part_draw_dsc.text = buf;
|
||||||
|
|
||||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ static void lv_spinbox_updatevalue(lv_obj_t * obj)
|
|||||||
int32_t i;
|
int32_t i;
|
||||||
char digits[LV_SPINBOX_MAX_DIGIT_COUNT + 4];
|
char digits[LV_SPINBOX_MAX_DIGIT_COUNT + 4];
|
||||||
/*Convert the numbers to string (the sign is already handled so always covert positive number)*/
|
/*Convert the numbers to string (the sign is already handled so always covert positive number)*/
|
||||||
lv_snprintf(digits, sizeof(digits), "%d", LV_ABS(spinbox->value));
|
lv_snprintf(digits, sizeof(digits), "%" LV_PRId32, LV_ABS(spinbox->value));
|
||||||
|
|
||||||
/*Add leading zeros*/
|
/*Add leading zeros*/
|
||||||
int lz_cnt = spinbox->digit_count - (int)strlen(digits);
|
int lz_cnt = spinbox->digit_count - (int)strlen(digits);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ void _lv_log_add(lv_log_level_t level, const char * file, int line, const char *
|
|||||||
char buf[512];
|
char buf[512];
|
||||||
uint32_t t = lv_tick_get();
|
uint32_t t = lv_tick_get();
|
||||||
static const char * lvl_prefix[] = {"Trace", "Info", "Warn", "Error", "User"};
|
static const char * lvl_prefix[] = {"Trace", "Info", "Warn", "Error", "User"};
|
||||||
lv_snprintf(buf, sizeof(buf), "[%s]\t(%d.%03d, +%d)\t %s: %s \t(in %s line #%d)\n", lvl_prefix[level], t / 1000, t % 1000, t - last_log_time, func, msg, &file[p], line);
|
lv_snprintf(buf, sizeof(buf), "[%s]\t(%" LV_PRId32 ".%03" LV_PRId32 ", +%" LV_PRId32 ")\t %s: %s \t(in %s line #%d)\n", lvl_prefix[level], t / 1000, t % 1000, t - last_log_time, func, msg, &file[p], line);
|
||||||
last_log_time = t;
|
last_log_time = t;
|
||||||
lv_log(buf);
|
lv_log(buf);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,15 @@
|
|||||||
#ifndef _LV_PRINTF_H_
|
#ifndef _LV_PRINTF_H_
|
||||||
#define _LV_PRINTF_H_
|
#define _LV_PRINTF_H_
|
||||||
|
|
||||||
|
/* not all compilers provide inttypes.h which would define these */
|
||||||
|
#include<limits.h>
|
||||||
|
|
||||||
|
#if LONG_MAX==2147483647
|
||||||
|
#define LV_PRId32 "ld"
|
||||||
|
#else
|
||||||
|
#define LV_PRId32 "d"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user