Skip to content

Commit ddce835

Browse files
committed
pbio/drv/display/display_ev3: make readonly data const
Data that never changes should be declared as const to allow the compiler to optimize it better and to prevent accidental modifications.
1 parent 290bb62 commit ddce835

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/pbio/drv/display/display_ev3.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static uint8_t pbdrv_display_user_frame[PBDRV_CONFIG_DISPLAY_NUM_ROWS][PBDRV_CON
140140
* Flag to indicate that the user frame has been updated and needs to be
141141
* encoded and sent to the display driver.
142142
*/
143-
static bool pbdrv_display_user_frame_update_requested = false;
143+
static bool pbdrv_display_user_frame_update_requested;
144144

145145
/**
146146
* Display buffer in the format ready for sending to the st7586s display driver.
@@ -194,7 +194,7 @@ static uint8_t encode_triplet(uint8_t p0, uint8_t p1, uint8_t p2) {
194194
*
195195
* Revisit: Use standard format, e.g. decompress PNG files from file storage or memory card.
196196
*/
197-
static uint16_t pbdrv_display_pybricks_logo[] = {
197+
static const uint16_t pbdrv_display_pybricks_logo[] = {
198198
3227, 3359, 3403, 3539, 3580, 3718, 3757, 3897, 3934, 4076, 4111, 4255, 4289, 4433, 4466, 4612,
199199
4644, 4790, 4822, 4968, 5000, 5146, 5178, 5324, 5356, 5502, 5534, 5548, 5666, 5680, 5712, 5725,
200200
5845, 5858, 5890, 5903, 6023, 6036, 6068, 6081, 6201, 6214, 6246, 6259, 6379, 6392, 6424, 6437,
@@ -235,7 +235,7 @@ static uint16_t pbdrv_display_pybricks_logo[] = {
235235
*
236236
* @param bitmap Pointer to the bitmap data.
237237
*/
238-
static void pbdrv_display_load_indexed_bitmap(uint16_t *indexed_bitmap) {
238+
static void pbdrv_display_load_indexed_bitmap(const uint16_t *indexed_bitmap) {
239239
bool set = 0;
240240
uint32_t switch_index = 0;
241241
for (size_t r = 0; r < PBDRV_CONFIG_DISPLAY_NUM_ROWS; r++) {
@@ -275,7 +275,7 @@ void pbdrv_display_st7586s_encode_user_frame(void) {
275275
/**
276276
* Display initialization script adapted from ev3dev and EV3RT.
277277
*/
278-
static pbdrv_display_st7586s_action_t init_script[] = {
278+
static const pbdrv_display_st7586s_action_t init_script[] = {
279279
#if ST7586S_DO_RESET_AND_INIT
280280
{ ST7586S_ACTION_WRITE_COMMAND, ST7586_ARDCTL},
281281
{ ST7586S_ACTION_WRITE_DATA, 0x9f},
@@ -475,7 +475,7 @@ PROCESS_THREAD(pbdrv_display_ev3_init_process, ev, data) {
475475
// For every action in the init script, either send a command or data, or
476476
// wait for a given delay.
477477
for (script_index = 0; script_index < PBIO_ARRAY_SIZE(init_script); script_index++) {
478-
pbdrv_display_st7586s_action_t *action = &init_script[script_index];
478+
const pbdrv_display_st7586s_action_t *action = &init_script[script_index];
479479

480480
if (action->type == ST7586S_ACTION_DELAY) {
481481
// Simple delay.

0 commit comments

Comments
 (0)