openchronos-ng
opensource firmware for the ez430 chronos
Data Structures | Typedefs | Enumerations | Functions
openchronos.h File Reference

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.

Detailed Description

Main openchronos-ng include file.


Enumeration Type Documentation

List of possible message types for the message bus.

See also:
sys_messagebus_register()
Enumerator:
SYS_MSG_RTC_ALARM 

alarm event from the hardware RTC.

SYS_MSG_RTC_MINUTE 

minute event from the hardware RTC.

SYS_MSG_RTC_HOUR 

hour event from the hardware RTC.

SYS_MSG_RTC_DAY 

day event from the hardware RTC.

SYS_MSG_RTC_MONTH 

month event from the hardware RTC.

SYS_MSG_RTC_YEAR 

year event from the hardware RTC.

SYS_MSG_TIMER_1HZ 

1HZ event from the hardware TIMER_0.

SYS_MSG_TIMER_20HZ 

20HZ event from the hardware TIMER_0.

SYS_MSG_TIMER_PROG 

programmable event from TIMER_0.


Function Documentation

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.

See also:
menu_editmode_start
Parameters:
valuevalue a pointer to the variable to be incremented.
lowerlower the lower bound for the loop interval.
upperupper the upper bound for the loop interval.
step1 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.

Note:
This function is NULL safe. You can set all of its parameters to NULL (except name) if you don't need their functionality.
The name string cannot be longer than 5 characters due to the LCD screen size.
Parameters:
nameitem name to be displayed in the menu
up_btn_fncallback for up button presses.
down_btn_fncallback for down button presses.
num_btn_fncallback for num button presses.
lstar_btn_fncallback for long star button presses.
lnum_btn_fncallback for long num button presses.
updown_btn_fncallback for up&down button presses.
activate_fncallback for when the user switches into this entry in the menu.
deactivate_fncallback 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.

Parameters:
complete_fncallback for when the user exits from the edit mode.
itemsA 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.

See also:
sys_message, sys_messagebus, sys_messagebus_unregister
Parameters:
callbackcallback to receive messages from the message bus
listensonly receive messages of this type
void sys_messagebus_unregister ( void(*)(enum sys_message callback)

Unregisters a node from the message bus.

See also:
sys_messagebus_register
Parameters:
callbackthe same callback used on sys_messagebus_register()
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines