summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey Castillo <jose.castillo@gmail.com>2021-08-07 11:22:49 -0400
committerJoey Castillo <jose.castillo@gmail.com>2021-08-07 11:22:49 -0400
commitf102be48642235a9d72b2159cc1c32cc83d0de8a (patch)
tree4f9314573b2e82472067d20461ea53c281c34190
parent8a49b9ae2be26cf6e4a3ab4283216eaf61117986 (diff)
downloadSensor-Watch-f102be48642235a9d72b2159cc1c32cc83d0de8a.tar.gz
Sensor-Watch-f102be48642235a9d72b2159cc1c32cc83d0de8a.tar.bz2
Sensor-Watch-f102be48642235a9d72b2159cc1c32cc83d0de8a.zip
segment lcd: add indicator methods, document character map
-rw-r--r--Sensor Watch BME280 Project/app.c4
-rw-r--r--watch-library/watch/watch.c65
-rw-r--r--watch-library/watch/watch.h34
3 files changed, 84 insertions, 19 deletions
diff --git a/Sensor Watch BME280 Project/app.c b/Sensor Watch BME280 Project/app.c
index e84e5760..9053ca65 100644
--- a/Sensor Watch BME280 Project/app.c
+++ b/Sensor Watch BME280 Project/app.c
@@ -114,7 +114,7 @@ bool app_loop() {
temperature = read_temperature(NULL);
sprintf(buf, "TE %4.1f#C", temperature);
watch_display_string(buf, 0);
- watch_clear_pixel(1, 16);
+ watch_clear_colon();
break;
case MODE_HUMIDITY:
// take one reading
@@ -126,7 +126,7 @@ bool app_loop() {
humidity = read_humidity(t_fine);
sprintf(buf, "HU rH %3d", (int)humidity);
watch_display_string(buf, 0);
- watch_set_pixel(1, 16);
+ watch_set_colon();
break;
case MODE_OFF:
watch_display_string(" Sleep ", 0);
diff --git a/watch-library/watch/watch.c b/watch-library/watch/watch.c
index 6931a73a..5d046925 100644
--- a/watch-library/watch/watch.c
+++ b/watch-library/watch/watch.c
@@ -22,20 +22,20 @@ void _watch_init() {
static const uint8_t Character_Set[] =
{
0b00000000, //
- 0b00000000, // !
+ 0b00000000, // ! (unused)
0b00100010, // "
0b01100011, // # (degree symbol, hash mark doesn't fit)
- 0b00000000, // $
- 0b00000000, // %
- 0b01000100, // &
+ 0b00000000, // $ (unused)
+ 0b00000000, // % (unused)
+ 0b01000100, // & ("lowercase 7" for positions 4 and 6)
0b00100000, // '
- 0b00000000, // (
- 0b00000000, // )
- 0b00000000, // *
- 0b11000000, // +
+ 0b00111001, // (
+ 0b00001111, // )
+ 0b00000000, // * (unused)
+ 0b11000000, // + (only works in position 0)
0b00000100, // ,
0b01000000, // -
- 0b01000000, // .
+ 0b01000000, // . (same as -, semantically most useful)
0b00010010, // /
0b00111111, // 0
0b00000110, // 1
@@ -47,13 +47,13 @@ static const uint8_t Character_Set[] =
0b00000111, // 7
0b01111111, // 8
0b01101111, // 9
- 0b00000000, // :
- 0b00000000, // ;
+ 0b00000000, // : (unused)
+ 0b00000000, // ; (unused)
0b01011000, // <
0b01001000, // =
0b01001100, // >
0b01010011, // ?
- 0b11111111, // @
+ 0b11111111, // @ (all segments on)
0b01110111, // A
0b01111111, // B
0b00111001, // C
@@ -64,7 +64,7 @@ static const uint8_t Character_Set[] =
0b01110110, // H
0b10001001, // I
0b00001110, // J
- 0b11101010, // K
+ 0b01110101, // K
0b00111000, // L
0b10110111, // M
0b00110111, // N
@@ -83,7 +83,7 @@ static const uint8_t Character_Set[] =
0b00111001, // [
0b00100100, // backslash
0b00001111, // ]
- 0b00100110, // ^
+ 0b00100011, // ^
0b00001000, // _
0b00000010, // `
0b01011111, // a
@@ -133,16 +133,24 @@ static const uint64_t Segment_Map[] = {
static const uint8_t Num_Chars = 10;
+static const uint32_t IndicatorSegments[6] = {
+ SLCD_SEGID(0, 17), // WATCH_INDICATOR_SENSING
+ SLCD_SEGID(0, 16), // WATCH_INDICATOR_BELL
+ SLCD_SEGID(2, 17), // WATCH_INDICATOR_PM
+ SLCD_SEGID(2, 16), // WATCH_INDICATOR_24H
+ SLCD_SEGID(1, 10), // WATCH_INDICATOR_LAP
+};
+
void watch_enable_display() {
SEGMENT_LCD_0_init();
slcd_sync_enable(&SEGMENT_LCD_0);
}
-void watch_set_pixel(uint8_t com, uint8_t seg) {
+inline void watch_set_pixel(uint8_t com, uint8_t seg) {
slcd_sync_seg_on(&SEGMENT_LCD_0, SLCD_SEGID(com, seg));
}
-void watch_clear_pixel(uint8_t com, uint8_t seg) {
+inline void watch_clear_pixel(uint8_t com, uint8_t seg) {
slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(com, seg));
}
@@ -175,6 +183,31 @@ void watch_display_string(char *string, uint8_t position) {
}
}
+inline void watch_set_colon() {
+ slcd_sync_seg_on(&SEGMENT_LCD_0, SLCD_SEGID(1, 16));
+}
+
+inline void watch_clear_colon() {
+ slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(1, 16));
+}
+
+inline void watch_set_indicator(WatchIndicatorSegment indicator) {
+ slcd_sync_seg_on(&SEGMENT_LCD_0, IndicatorSegments[indicator]);
+}
+
+inline void watch_clear_indicator(WatchIndicatorSegment indicator) {
+ slcd_sync_seg_off(&SEGMENT_LCD_0, IndicatorSegments[indicator]);
+}
+
+void watch_clear_all_indicators() {
+ slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(2, 17));
+ slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(2, 16));
+ slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(0, 17));
+ slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(0, 16));
+ slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(1, 10));
+}
+
+
//////////////////////////////////////////////////////////////////////////////////////////
// Buttons
diff --git a/watch-library/watch/watch.h b/watch-library/watch/watch.h
index c842d727..0f70890c 100644
--- a/watch-library/watch/watch.h
+++ b/watch-library/watch/watch.h
@@ -108,6 +108,15 @@ void _watch_init();
* for displaying strings of characters and indicators on the main watch display.
*/
/// @{
+
+typedef enum WatchIndicatorSegment {
+ WATCH_INDICATOR_SENSING = 0,
+ WATCH_INDICATOR_BELL,
+ WATCH_INDICATOR_PM,
+ WATCH_INDICATOR_24H,
+ WATCH_INDICATOR_LAP
+} WatchIndicatorSegment;
+
/** @brief Enables the Segment LCD display.
* Call this before attempting to set pixels or display strings.
*/
@@ -122,7 +131,6 @@ void watch_set_pixel(uint8_t com, uint8_t seg);
/** @brief Clears a pixel. Use this to manually clear a pixel with a given common and segment number.
* @param com the common pin, numbered from 0-2.
* @param seg the segment pin, numbered from 0-23.
- * Use this to manually set a pixel with a common and a segment number.
*/
void watch_clear_pixel(uint8_t com, uint8_t seg);
@@ -136,6 +144,30 @@ void watch_clear_pixel(uint8_t com, uint8_t seg);
position 0, positions 2-9 will retain whatever state they were previously displaying.
*/
void watch_display_string(char *string, uint8_t position);
+
+/** @brief Turns the colon segment on.
+ */
+void watch_set_colon();
+
+/** @brief Turns the colon segment off.
+ */
+void watch_clear_colon();
+
+/** @brief Sets an indicator on the LCD. Use this to turn on one of the indicator segments.
+ * @param indicator One of the indicator segments from the enum. @see WatchIndicatorSegment
+ */
+void watch_set_indicator(WatchIndicatorSegment indicator);
+
+/** @brief Clears an indicator on the LCD. Use this to turn off one of the indicator segments.
+ * @param indicator One of the indicator segments from the enum. @see WatchIndicatorSegment
+ */
+void watch_clear_indicator(WatchIndicatorSegment indicator);
+
+/** @brief Clears all indicator segments.
+ * @see WatchIndicatorSegment
+ */
+void watch_clear_all_indicators();
+
/// @}