1 /* 2 * Copyright (c) 2024 Glenn Andrews 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef SMF_CALCULATOR_THREAD_H_ 8 #define SMF_CALCULATOR_THREAD_H_ 9 10 #include <zephyr/kernel.h> 11 12 #define SMF_THREAD_STACK_SIZE 1024 13 #define SMF_THREAD_PRIORITY 7 14 15 #define CALCULATOR_MAX_DIGITS 15 16 17 /* Add one byte for '-' sign, one for trailing '\0' */ 18 #define CALCULATOR_STRING_LENGTH (CALCULATOR_MAX_DIGITS + 2) 19 20 enum calculator_events { 21 DIGIT_0, 22 DIGIT_1_9, 23 DECIMAL_POINT, 24 OPERATOR, 25 EQUALS, 26 CANCEL_ENTRY, 27 CANCEL_BUTTON, 28 }; 29 30 struct calculator_event { 31 enum calculator_events event_id; 32 char operand; 33 }; 34 35 /* event queue to post messages to */ 36 extern struct smf_event_queue smf_thread_event_queue; 37 38 int post_calculator_event(struct calculator_event *event, k_timeout_t timeout); 39 40 #endif /* SMF_CALCULATOR_THREAD_H_ */ 41