GPS Device
Loading...
Searching...
No Matches
SSD1309 Command Handlers

Functions

static ERR_te ssd1309_cmd_start_handler (uint32_t argc, char **argv)
 CLI handler for the "start" command. Starts the SSD1309 subsystem at runtime.
static ERR_te ssd1309_cmd_stop_handler (uint32_t argc, char **argv)
 CLI handler for the "stop" command. Stops the SSD1309 subsystem at runtime.
static ERR_te ssd1309_cmd_fillrect_handler (uint32_t argc, char **argv)
 CLI handler for the "fillrect" command. Fills a rectangle and updates the display.
static ERR_te ssd1309_cmd_clearrect_handler (uint32_t argc, char **argv)
 CLI handler for the "clearrect" command. Clears a rectangle and updates the display.
static ERR_te ssd1309_cmd_invertrect_handler (uint32_t argc, char **argv)
 CLI handler for the "invertrect" command. Inverts a rectangle and updates the display.
static ERR_te ssd1309_cmd_drawtext_handler (uint32_t argc, char **argv)
 CLI handler for the "drawtext" command. Draws text on a line and updates the display.
static ERR_te ssd1309_cmd_clearline_handler (uint32_t argc, char **argv)
 CLI handler for the "clearline" command. Clears a line and updates the display.
static ERR_te ssd1309_cmd_invertline_handler (uint32_t argc, char **argv)
 CLI handler for the "invertline" command. Inverts a line and updates the display.

Detailed Description

Function Documentation

◆ ssd1309_cmd_start_handler()

ERR_te ssd1309_cmd_start_handler ( uint32_t argc,
char ** argv )
static

CLI handler for the "start" command. Starts the SSD1309 subsystem at runtime.

Expected invocation: ssd1309 start

Parameters
[in]argcArgument count. Must be exactly 2.
[in]argvArgument list: argv[0] = "ssd1309", argv[1] = "start".
Returns
  • ERR_OK on success
  • ERR_INVALID_ARGUMENT if argc != 2

Definition at line 1111 of file ssd1309.c.

1111 {
1112 if(argc != 2) {
1113 LOG_ERROR(
1114 internal_state.subsys,
1115 internal_state.log_level,
1116 "ssd1309_cmd_start_handler: invalid arguments"
1117 );
1118
1119 return ERR_INVALID_ARGUMENT;
1120 }
1121
1122 internal_state.started = true;
1123
1124 return ERR_OK;
1125}
static struct internal_state_s internal_state
Singleton instance of the SysTick driver internal state.
@ ERR_OK
Definition err.h:36
@ ERR_INVALID_ARGUMENT
Definition err.h:38
#define LOG_ERROR(subsys, lvl, fmt,...)
Definition log.h:258

◆ ssd1309_cmd_stop_handler()

ERR_te ssd1309_cmd_stop_handler ( uint32_t argc,
char ** argv )
static

CLI handler for the "stop" command. Stops the SSD1309 subsystem at runtime.

Expected invocation: ssd1309 stop

Parameters
[in]argcArgument count. Must be exactly 2.
[in]argvArgument list: argv[0] = "ssd1309", argv[1] = "stop".
Returns
  • ERR_OK on success
  • ERR_INVALID_ARGUMENT if argc != 2

Definition at line 1140 of file ssd1309.c.

1140 {
1141 if(argc != 2) {
1142 LOG_ERROR(
1143 internal_state.subsys,
1144 internal_state.log_level,
1145 "ssd1309_cmd_stop_handler: invalid arguments"
1146 );
1147
1148 return ERR_INVALID_ARGUMENT;
1149 }
1150
1151 internal_state.started = false;
1152
1153 return ERR_OK;
1154}

◆ ssd1309_cmd_fillrect_handler()

ERR_te ssd1309_cmd_fillrect_handler ( uint32_t argc,
char ** argv )
static

CLI handler for the "fillrect" command. Fills a rectangle and updates the display.

Expected invocation: ssd1309 fillrect <x1> <y1> <x2> <y2>

Coordinates are 1-based. Calls ssd1309_draw_rect with force=true, then ssd1309_update with force=true.

Parameters
[in]argcArgument count. Must be exactly 6.
[in]argvargv[2]–argv[5] = x1, y1, x2, y2 as decimal strings.
Returns
  • ERR_OK on success
  • ERR_INVALID_ARGUMENT if argc != 6 or coordinates are out of range

Definition at line 1172 of file ssd1309.c.

1172 {
1173 ERR_te err;
1174
1175 if(argc != 6) {
1176 LOG_ERROR(
1177 internal_state.subsys,
1178 internal_state.log_level,
1179 "ssd1309_cmd_fillrect_handler: invalid arguments"
1180 );
1181
1182 return ERR_INVALID_ARGUMENT;
1183 }
1184
1185 int x1 = str_to_int(argv[2]);
1186 int y1 = str_to_int(argv[3]);
1187 int x2 = str_to_int(argv[4]);
1188 int y2 = str_to_int(argv[5]);
1189
1190 if(
1191 (x1 < 1 || x1 > SSD1309_WIDTH) ||
1192 (y1 < 1 || y1 > SSD1309_HEIGHT) ||
1193 (x2 < 1 || x2 > SSD1309_WIDTH) ||
1194 (y2 < 1 || y2 > SSD1309_HEIGHT)
1195 ) {
1196 LOG_ERROR(
1197 internal_state.subsys,
1198 internal_state.log_level,
1199 "ssd1309_cmd_fillrect_handler: invalid arguments"
1200 );
1201
1202 return ERR_INVALID_ARGUMENT;
1203 }
1204
1205 err = ssd1309_draw_rect(x1, y1, x2, y2, true);
1206 if(err != ERR_OK) {
1207 LOG_ERROR(
1208 internal_state.subsys,
1209 internal_state.log_level,
1210 "ssd1309_cmd_fillrect_handler: invalid arguments"
1211 );
1212
1213 return ERR_INVALID_ARGUMENT;
1214 }
1215
1216 ssd1309_update(true);
1217
1218 return ERR_OK;
1219}
int str_to_int(const char *str)
Converts a decimal string to an integer.
Definition common.c:69
ERR_te
Standard return type used by all public API functions.
Definition err.h:35
#define SSD1309_HEIGHT
Definition ssd1309.h:62
#define SSD1309_WIDTH
Definition ssd1309.h:61
ERR_te ssd1309_update(bool force)
Flushes the internal framebuffer to the display over I2C.
Definition ssd1309.c:1064
ERR_te ssd1309_draw_rect(uint8_t x_src, uint8_t y_src, uint8_t x_dest, uint8_t y_dest, bool force)
Draws a filled rectangle into the framebuffer.
Definition ssd1309.c:843
Here is the call graph for this function:

◆ ssd1309_cmd_clearrect_handler()

ERR_te ssd1309_cmd_clearrect_handler ( uint32_t argc,
char ** argv )
static

CLI handler for the "clearrect" command. Clears a rectangle and updates the display.

Expected invocation: ssd1309 clearrect <x1> <y1> <x2> <y2>

Parameters
[in]argcArgument count. Must be exactly 6.
[in]argvargv[2]–argv[5] = x1, y1, x2, y2 as decimal strings.
Returns
  • ERR_OK on success
  • ERR_INVALID_ARGUMENT if argc != 6 or coordinates are out of range

Definition at line 1234 of file ssd1309.c.

1234 {
1235 ERR_te err;
1236
1237 if(argc != 6) {
1238 LOG_ERROR(
1239 internal_state.subsys,
1240 internal_state.log_level,
1241 "ssd1309_cmd_clearrect_handler: invalid arguments"
1242 );
1243
1244 return ERR_INVALID_ARGUMENT;
1245 }
1246
1247 int x1 = str_to_int(argv[2]);
1248 int y1 = str_to_int(argv[3]);
1249 int x2 = str_to_int(argv[4]);
1250 int y2 = str_to_int(argv[5]);
1251
1252 if(
1253 (x1 < 1 || x1 > SSD1309_WIDTH) ||
1254 (y1 < 1 || y1 > SSD1309_HEIGHT) ||
1255 (x2 < 1 || x2 > SSD1309_WIDTH) ||
1256 (y2 < 1 || y2 > SSD1309_HEIGHT)
1257 ) {
1258 LOG_ERROR(
1259 internal_state.subsys,
1260 internal_state.log_level,
1261 "ssd1309_cmd_clearrect_handler: invalid arguments"
1262 );
1263
1264 return ERR_INVALID_ARGUMENT;
1265 }
1266
1267 err = ssd1309_clear_rect(x1, y1, x2, y2, true);
1268 if(err != ERR_OK) {
1269 LOG_ERROR(
1270 internal_state.subsys,
1271 internal_state.log_level,
1272 "ssd1309_cmd_clearrect_handler: invalid arguments"
1273 );
1274
1275 return ERR_INVALID_ARGUMENT;
1276 }
1277
1278 ssd1309_update(true);
1279
1280 return ERR_OK;
1281}
ERR_te ssd1309_clear_rect(uint8_t x_src, uint8_t y_src, uint8_t x_dest, uint8_t y_dest, bool force)
Clears a rectangular region in the framebuffer.
Definition ssd1309.c:947
Here is the call graph for this function:

◆ ssd1309_cmd_invertrect_handler()

ERR_te ssd1309_cmd_invertrect_handler ( uint32_t argc,
char ** argv )
static

CLI handler for the "invertrect" command. Inverts a rectangle and updates the display.

Expected invocation: ssd1309 invertrect <x1> <y1> <x2> <y2>

Parameters
[in]argcArgument count. Must be exactly 6.
[in]argvargv[2]–argv[5] = x1, y1, x2, y2 as decimal strings.
Returns
  • ERR_OK on success
  • ERR_INVALID_ARGUMENT if argc != 6 or coordinates are out of range

Definition at line 1296 of file ssd1309.c.

1296 {
1297 ERR_te err;
1298
1299 if(argc != 6) {
1300 LOG_ERROR(
1301 internal_state.subsys,
1302 internal_state.log_level,
1303 "ssd1309_cmd_invertrect_handler: invalid arguments"
1304 );
1305
1306 return ERR_INVALID_ARGUMENT;
1307 }
1308
1309 int x1 = str_to_int(argv[2]);
1310 int y1 = str_to_int(argv[3]);
1311 int x2 = str_to_int(argv[4]);
1312 int y2 = str_to_int(argv[5]);
1313
1314 if(
1315 (x1 < 1 || x1 > SSD1309_WIDTH) ||
1316 (y1 < 1 || y1 > SSD1309_HEIGHT) ||
1317 (x2 < 1 || x2 > SSD1309_WIDTH) ||
1318 (y2 < 1 || y2 > SSD1309_HEIGHT)
1319 ) {
1320 LOG_ERROR(
1321 internal_state.subsys,
1322 internal_state.log_level,
1323 "ssd1309_cmd_invertrect_handler: invalid arguments"
1324 );
1325
1326 return ERR_INVALID_ARGUMENT;
1327 }
1328
1329 err = ssd1309_invert_rect(x1, y1, x2, y2, true);
1330 if(err != ERR_OK) {
1331 LOG_ERROR(
1332 internal_state.subsys,
1333 internal_state.log_level,
1334 "ssd1309_cmd_invertrect_handler: invalid arguments"
1335 );
1336
1337 return ERR_INVALID_ARGUMENT;
1338 }
1339
1340 ssd1309_update(true);
1341
1342 return ERR_OK;
1343}
ERR_te ssd1309_invert_rect(uint8_t x_src, uint8_t y_src, uint8_t x_dest, uint8_t y_dest, bool force)
Inverts all pixels in a rectangular region of the framebuffer.
Definition ssd1309.c:1005
Here is the call graph for this function:

◆ ssd1309_cmd_drawtext_handler()

ERR_te ssd1309_cmd_drawtext_handler ( uint32_t argc,
char ** argv )
static

CLI handler for the "drawtext" command. Draws text on a line and updates the display.

Expected invocation: ssd1309 drawtext <text> <line>

Parameters
[in]argcArgument count. Must be exactly 4.
[in]argvargv[2] = text string, argv[3] = line number (1–8) as decimal string.
Returns
  • ERR_OK on success
  • ERR_INVALID_ARGUMENT if argc != 4 or line is out of range
  • Propagated error from ssd1309_draw_text on failure

Definition at line 1359 of file ssd1309.c.

1359 {
1360 ERR_te err;
1361
1362 if(argc != 4) {
1363 LOG_ERROR(
1364 internal_state.subsys,
1365 internal_state.log_level,
1366 "ssd1309_cmd_drawtext_handler: invalid arguments"
1367 );
1368
1369 return ERR_INVALID_ARGUMENT;
1370 }
1371
1372 uint8_t line = str_to_int(argv[3]);
1373 if(line > SSD1309_MAX_LINES) {
1374 LOG_ERROR(
1375 internal_state.subsys,
1376 internal_state.log_level,
1377 "ssd1309_cmd_drawtext_handler: invalid arguments"
1378 );
1379
1380 return ERR_INVALID_ARGUMENT;
1381 }
1382
1383 err = ssd1309_draw_text(argv[2], get_str_len(argv[2]), line, true);
1384 if(err != ERR_OK) {
1385 return err;
1386 }
1387
1388 ssd1309_update(true);
1389
1390 return ERR_OK;
1391}
uint32_t get_str_len(char const *str)
Returns the length of a string, excluding the null terminator.
Definition common.c:22
ERR_te ssd1309_draw_text(char const *text, uint8_t text_len, uint8_t line, bool force)
Draws a text string into the framebuffer at the specified line.
Definition ssd1309.c:806
#define SSD1309_MAX_LINES
Maximum number of text lines on the display (one per page).
Definition ssd1309.c:36
Here is the call graph for this function:

◆ ssd1309_cmd_clearline_handler()

ERR_te ssd1309_cmd_clearline_handler ( uint32_t argc,
char ** argv )
static

CLI handler for the "clearline" command. Clears a line and updates the display.

Expected invocation: ssd1309 clearline <line>

Parameters
[in]argcArgument count. Must be exactly 3.
[in]argvargv[2] = line number (1–8) as decimal string.
Returns
  • ERR_OK on success
  • ERR_INVALID_ARGUMENT if argc != 3 or line is out of range
  • Propagated error from ssd1309_clear_line on failure

Definition at line 1407 of file ssd1309.c.

1407 {
1408 ERR_te err;
1409
1410 if(argc != 3) {
1411 LOG_ERROR(
1412 internal_state.subsys,
1413 internal_state.log_level,
1414 "ssd1309_cmd_clearline_handler: invalid arguments"
1415 );
1416
1417 return ERR_INVALID_ARGUMENT;
1418 }
1419
1420 uint8_t line = str_to_int(argv[2]);
1421 if(line > SSD1309_MAX_LINES) {
1422 LOG_ERROR(
1423 internal_state.subsys,
1424 internal_state.log_level,
1425 "ssd1309_cmd_clearline_handler: invalid arguments"
1426 );
1427
1428 return ERR_INVALID_ARGUMENT;
1429 }
1430
1431 err = ssd1309_clear_line(line, true);
1432 if(err != ERR_OK) {
1433 return err;
1434 }
1435
1436 ssd1309_update(true);
1437
1438 return ERR_OK;
1439}
ERR_te ssd1309_clear_line(uint8_t line, bool force)
Clears a single display line in the framebuffer.
Definition ssd1309.c:901
Here is the call graph for this function:

◆ ssd1309_cmd_invertline_handler()

ERR_te ssd1309_cmd_invertline_handler ( uint32_t argc,
char ** argv )
static

CLI handler for the "invertline" command. Inverts a line and updates the display.

Expected invocation: ssd1309 invertline <line>

Parameters
[in]argcArgument count. Must be exactly 3.
[in]argvargv[2] = line number (1–8) as decimal string.
Returns
  • ERR_OK on success
  • ERR_INVALID_ARGUMENT if argc != 3 or line is out of range
  • Propagated error from ssd1309_invert_line on failure

Definition at line 1455 of file ssd1309.c.

1455 {
1456 ERR_te err;
1457
1458 if(argc != 3) {
1459 LOG_ERROR(
1460 internal_state.subsys,
1461 internal_state.log_level,
1462 "ssd1309_cmd_invertline_handler: invalid arguments"
1463 );
1464
1465 return ERR_INVALID_ARGUMENT;
1466 }
1467
1468 uint8_t line = str_to_int(argv[2]);
1469 if(line > SSD1309_MAX_LINES) {
1470 LOG_ERROR(
1471 internal_state.subsys,
1472 internal_state.log_level,
1473 "ssd1309_cmd_invertline_handler: invalid arguments"
1474 );
1475
1476 return ERR_INVALID_ARGUMENT;
1477 }
1478
1479 err = ssd1309_invert_line(line, true);
1480 if(err != ERR_OK) {
1481 return err;
1482 }
1483
1484 ssd1309_update(true);
1485
1486 return ERR_OK;
1487}
ERR_te ssd1309_invert_line(uint8_t line, bool force)
Inverts all pixels in a single display line in the framebuffer.
Definition ssd1309.c:924
Here is the call graph for this function: