openchronos-ng
opensource firmware for the ez430 chronos
|
Main openchronos-ng include file. More...
#include <msp430.h>
#include <stdlib.h>
#include "config.h"
Go to the source code of this file.
Data Structures | |
struct | menu_editmode_item |
A item structure for menu_editmode_start. More... | |
struct | sys_messagebus |
Linked list of nodes listening to the message bus. More... | |
Typedefs | |
typedef void(* | helpers_loop_fn_t )(uint8_t *, uint8_t, uint8_t, int8_t) |
Handy prototype typedef for helpers_loop() function. | |
Enumerations | |
enum | sys_message { SYS_MSG_RTC_ALARM = BIT0, SYS_MSG_RTC_MINUTE = BIT1, SYS_MSG_RTC_HOUR = BIT2, SYS_MSG_RTC_DAY = BIT3, SYS_MSG_RTC_MONTH = BIT4, SYS_MSG_RTC_YEAR = BIT5, SYS_MSG_TIMER_1HZ = BIT6, SYS_MSG_TIMER_20HZ = BIT7, SYS_MSG_TIMER_PROG = BIT8 } |
List of possible message types for the message bus. More... | |
Functions | |
void | menu_add_entry (char const *name, void(*up_btn_fn)(void), void(*down_btn_fn)(void), void(*num_btn_fn)(void), void(*lstar_btn_fn)(void), void(*lnum_btn_fn)(void), void(*updown_btn_fn)(void), void(*activate_fn)(void), void(*deactivate_fn)(void)) |
Adds an entry to the main menu. | |
void | menu_editmode_start (void(*complete_fn)(void), struct menu_editmode_item *items) |
Enters edit mode. | |
void | helpers_loop (uint8_t *value, uint8_t lower, uint8_t upper, int8_t step) |
Increment/decrements value by one without exiting the [lower, upper] interval. | |
void | sys_messagebus_register (void(*callback)(enum sys_message), enum sys_message listens) |
Registers a node in the message bus. | |
void | sys_messagebus_unregister (void(*callback)(enum sys_message)) |
Unregisters a node from the message bus. |
Main openchronos-ng include file.
enum sys_message |
List of possible message types for the message bus.
void helpers_loop | ( | uint8_t * | value, |
uint8_t | lower, | ||
uint8_t | upper, | ||
int8_t | step | ||
) |
Increment/decrements value by one without exiting the [lower, upper] interval.
Increment/decrements value by one without exiting the [lower, upper] interval. If the value meets the upper bound, it is restarted from lower bound. If the value meets the lower bound, it is restarded from the upper bound.
Note: For now, only steps of -1 and 1 are considered.
value | value a pointer to the variable to be incremented. |
lower | lower the lower bound for the loop interval. |
upper | upper the upper bound for the loop interval. |
step | 1 for incrementing value, -1 for a decrement |
void menu_add_entry | ( | char const * | name, |
void(*)(void) | up_btn_fn, | ||
void(*)(void) | down_btn_fn, | ||
void(*)(void) | num_btn_fn, | ||
void(*)(void) | lstar_btn_fn, | ||
void(*)(void) | lnum_btn_fn, | ||
void(*)(void) | updown_btn_fn, | ||
void(*)(void) | activate_fn, | ||
void(*)(void) | deactivate_fn | ||
) |
Adds an entry to the main menu.
This function is to be used by modules, so that they can be visible in the main menu. A good place to call this function is from the corresponding module's _init function.
name | item name to be displayed in the menu |
up_btn_fn | callback for up button presses. |
down_btn_fn | callback for down button presses. |
num_btn_fn | callback for num button presses. |
lstar_btn_fn | callback for long star button presses. |
lnum_btn_fn | callback for long num button presses. |
updown_btn_fn | callback for up&down button presses. |
activate_fn | callback for when the user switches into this entry in the menu. |
deactivate_fn | callback for when the user switches out from this entry in the menu. |
void menu_editmode_start | ( | void(*)(void) | complete_fn, |
struct menu_editmode_item * | items | ||
) |
Enters edit mode.
The edit mode is a mechanism that allows the user to change values being displayed in the screen. For example, if a clock alarm is being displayed, then edit mode can be used to increase/decrease the values of hours and minutes. A good place to call this function is from the module's lstar_btn_fn function (see menu_add_entry()).
See modules/alarm.c for an example how to use this.
complete_fn | callback for when the user exits from the edit mode. |
items | A vector of menu_editmode_item, it must be NULL terminated! |
void sys_messagebus_register | ( | void(*)(enum sys_message) | callback, |
enum sys_message | listens | ||
) |
Registers a node in the message bus.
Registers (add) a node to the message bus. A node can filter what message(s) are to be received by setting the bitfield listens.
callback | callback to receive messages from the message bus |
listens | only receive messages of this type |
void sys_messagebus_unregister | ( | void(*)(enum sys_message) | callback | ) |
Unregisters a node from the message bus.
callback | the same callback used on sys_messagebus_register() |