Skip to content

Commit 96a5686

Browse files
committed
add control flags for clock mode
1 parent 2ab7dca commit 96a5686

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

module_seven_seg/src/seven_seg.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#ifndef __SEVEN_SEG_H__
77
#define __SEVEN_SEG_H__
88

9+
// setClock flags
10+
#define SSEG_AM_PM 0x01 // enable 12 hour clock mode
11+
#define SSEG_COLON 0x02 // enable colon in clock display
12+
913
// driver interface
1014
interface seven_seg_if {
1115

@@ -21,10 +25,11 @@ interface seven_seg_if {
2125
// show value with optional decimal places, optional leading zeros
2226
[[clears_notification]] void setValue(uint32_t value, uint8_t dplaces, uint8_t lead_0s);
2327

24-
// show clock display with optional am-pm format
25-
[[clears_notification]] void setClock(uint8_t hours, uint8_t minutes, uint8_t am_pm);
28+
// show clock display with optional format flags: bit0=am_pm, bit1=colon
29+
[[clears_notification]] void setClock(uint8_t hours, uint8_t minutes, uint8_t flags);
2630
};
2731

32+
[[combinable]]
2833
void seven_seg_task(port txd, interface seven_seg_if server dvr);
2934

3035

module_seven_seg/src/seven_seg.xc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// ---------------------------------------------------------
1212
// seven_seg_task - Serial 7 segment display driver
1313
//
14+
[[combinable]]
1415
void seven_seg_task(port txd, interface seven_seg_if server display) {
1516
const uint32_t bit_rate = (100*1000*1000)/9600;
1617
uint8_t latest_ascii[4] = {0,0,0,0};
@@ -43,10 +44,11 @@ void seven_seg_task(port txd, interface seven_seg_if server display) {
4344
}
4445
display_updated = 1;
4546
break;
46-
case display.setClock(uint8_t hours, uint8_t minutes, uint8_t am_pm):
47+
case display.setClock(uint8_t hours, uint8_t minutes, uint8_t flags):
4748
hours = (23<hours)? 23 : hours;
4849
minutes = (59<minutes)? 59 : minutes;
49-
latest_dp = 0x10;
50+
latest_dp = (SSEG_COLON&flags)? 0x10 : 0;
51+
uint8_t am_pm = SSEG_AM_PM & flags;
5052
if ( am_pm ) {
5153
if ( 12 <= hours ) {
5254
latest_dp |= 0x08;

0 commit comments

Comments
 (0)