gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
slcd.h
1
2/*
3 * MIT License
4 *
5 * Copyright (c) 2023 Joey Castillo
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
26#pragma once
27
28#include <stdint.h>
29#include <stdbool.h>
30#include <stddef.h>
31#include "system.h"
32
39#ifdef SLCD
40
41typedef enum {
42 SLCD_BIAS_STATIC = 0,
43 SLCD_BIAS_HALF = 1,
44 SLCD_BIAS_THIRD = 2,
45 SLCD_BIAS_FOURTH = 3,
46} slcd_bias_value_t;
47
48typedef enum {
49 SLCD_DUTY_1_COMMON = 0,
50 SLCD_DUTY_2_COMMON = 1,
51 SLCD_DUTY_3_COMMON = 2,
52 SLCD_DUTY_4_COMMON = 3,
53 SLCD_DUTY_6_COMMON = 4,
54 SLCD_DUTY_8_COMMON = 5,
55} slcd_duty_value_t;
56
57typedef enum {
58 SLCD_PRESCALER_DIV16 = 0,
59 SLCD_PRESCALER_DIV32 = 1,
60 SLCD_PRESCALER_DIV64 = 2,
61 SLCD_PRESCALER_DIV128 = 3,
62} slcd_prescaler_value_t;
63
64typedef enum {
65 SLCD_CLOCKSOURCE_ULP = 0,
66 SLCD_CLOCKSOURCE_XOSC = 1,
67} slcd_clocksource_value_t;
68
69typedef enum {
70 SLCD_CLOCKDIV_1 = 0,
71 SLCD_CLOCKDIV_2 = 1,
72 SLCD_CLOCKDIV_3 = 2,
73 SLCD_CLOCKDIV_4 = 3,
74 SLCD_CLOCKDIV_5 = 4,
75 SLCD_CLOCKDIV_6 = 5,
76 SLCD_CLOCKDIV_7 = 6,
77 SLCD_CLOCKDIV_8 = 7,
78} slcd_clockdiv_value_t;
79
80typedef enum {
81 SLCD_CSRSHIFT_LEFT = 0,
82 SLCD_CSRSHIFT_RIGHT = 1,
83} slcd_csrshift_value_t;
84
139void slcd_init(uint64_t lcd_pins, slcd_bias_value_t bias, slcd_duty_value_t duty, slcd_clocksource_value_t clocksource, slcd_prescaler_value_t prescaler, slcd_clockdiv_value_t clkdiv);
140
148void slcd_set_contrast(uint8_t contrast);
149
153void slcd_enable(void);
154
158void slcd_clear(void);
159
165void slcd_set_segment(uint8_t com, uint8_t seg);
166
172void slcd_clear_segment(uint8_t com, uint8_t seg);
173
183void slcd_configure_frame_counter(uint8_t fc, uint8_t overflow_count, bool prescale);
184
191void slcd_set_frame_counter_enabled(uint8_t fc, bool enabled);
192
204void slcd_configure_blink(bool blink_all, uint8_t bss0, uint8_t bss1, uint8_t fc);
205
211void slcd_set_blink_enabled(bool enabled);
212
222void slcd_configure_circular_shift_animation(uint16_t initial_value, uint8_t size, slcd_csrshift_value_t shift_dir, uint8_t fc);
223
231
235void slcd_disable(void);
236
237
238#endif // SLCD
239
void slcd_disable(void)
Disables the SLCD peripheral.
Definition slcd.c:166
void slcd_init(uint64_t lcd_pins, slcd_bias_value_t bias, slcd_duty_value_t duty, slcd_clocksource_value_t clocksource, slcd_prescaler_value_t prescaler, slcd_clockdiv_value_t clkdiv)
Initializes the SLCD peripheral, but does not enable it.
Definition slcd.c:34
void slcd_clear_segment(uint8_t com, uint8_t seg)
Clears a segment in the display memory.
Definition slcd.c:101
void slcd_configure_frame_counter(uint8_t fc, uint8_t overflow_count, bool prescale)
Configures one of the three frame counters.
Definition slcd.c:105
void slcd_set_circular_shift_animation_enabled(bool enabled)
Enables or disables circular shift register animation according to the configuration set by slcd_conf...
Definition slcd.c:161
void slcd_configure_circular_shift_animation(uint16_t initial_value, uint8_t size, slcd_csrshift_value_t shift_dir, uint8_t fc)
Configures the Circular Shift Register animation, but does not start it. This is pretty obscure and y...
Definition slcd.c:154
void slcd_set_frame_counter_enabled(uint8_t fc, bool enabled)
Enables or disables one of the three frame counters.
Definition slcd.c:121
void slcd_set_contrast(uint8_t contrast)
Sets the contrast level for the display. Valid values are from 0-15.
Definition slcd.c:66
void slcd_configure_blink(bool blink_all, uint8_t bss0, uint8_t bss1, uint8_t fc)
Configures the blink mode, but does not start blinking.
Definition slcd.c:138
void slcd_set_blink_enabled(bool enabled)
Enables or disables blinking according to the configuration set by slcd_configure_blink.
Definition slcd.c:149
void slcd_clear(void)
Clears all display memory.
Definition slcd.c:75
void slcd_enable(void)
Enables the SLCD peripheral.
Definition slcd.c:70
void slcd_set_segment(uint8_t com, uint8_t seg)
Sets a segment in the display memory.
Definition slcd.c:97