Taiga Develop 2 nedēļas atpakaļ
vecāks
revīzija
9320248dc4

+ 13 - 0
include/cx/chlcd.h

@@ -0,0 +1,13 @@
+#ifndef CX_CHLCD_H_INCLUDED
+#define CX_CHLCD_H_INCLUDED
+
+#include "chlcd/types.h"
+#include "chlcd/error.h"
+#include "chlcd/command.h"
+#include "chlcd/connector.h"
+#include "chlcd/creator.h"
+#include "chlcd/decoder.h"
+#include "chlcd/display.h"
+#include "chlcd/sender.h"
+
+#endif

+ 12 - 0
include/cx/chlcd/api.h

@@ -0,0 +1,12 @@
+#ifndef CX_CHLCD_API_H_INCLUDED
+#define CX_CHLCD_API_H_INCLUDED
+
+#include "chlcd/types.h"
+#include "chlcd/error.h"
+#include "chlcd/display.h"
+
+chlcd_error_t chlcd_display_init(chlcd_display_t *self);
+chlcd_error_t chlcd_display_clear(chlcd_display_t *self);
+chlcd_error_t chlcd_display_print(chlcd_display_t *self, char *content);
+
+#endif

+ 14 - 0
include/cx/chlcd/command.h

@@ -0,0 +1,14 @@
+#ifndef CX_CHLCD_COMMAND_H_INCLUDED
+#define CX_CHLCD_COMMAND_H_INCLUDED
+
+typedef enum chlcd_command_e {
+    RESET,
+    INIT,
+    CLEAR,
+    SHOW_CURSOR,
+    HIDE_CURSOR,
+    MOVE_CURSOR,
+    SEND_CHAR
+} chlcd_command_t;
+
+#endif

+ 28 - 0
include/cx/chlcd/connector.h

@@ -0,0 +1,28 @@
+#ifndef CX_CHLCD_CONNECTOR_H_INCLUDED
+#define CX_CHLCD_CONNECTOR_H_INCLUDED
+
+#include "chlcd/types.h"
+
+typedef struct chlcd_hd44780_direct_connector_s {
+    chlcd_pin_t e;
+    chlcd_pin_t rs;
+    chlcd_pin_t d4;
+    chlcd_pin_t d5;
+    chlcd_pin_t d6;
+    chlcd_pin_t d7;
+} chlcd_hd44780_direct_connector_t;
+
+typedef struct chlcd_hd44780_shift_register_connector_s {
+    chlcd_pin_t register_latch;
+    chlcd_pin_t register_clock;
+    chlcd_pin_t register_data;
+   
+    chlcd_bitcount_t e;
+    chlcd_bitcount_t rs;
+    chlcd_bitcount_t d4;
+    chlcd_bitcount_t d5;
+    chlcd_bitcount_t d6;
+    chlcd_bitcount_t d7;
+} chlcd_hd44780_shift_register_connector_t;
+
+#endif

+ 23 - 0
include/cx/chlcd/creator.h

@@ -0,0 +1,23 @@
+#ifndef CX_CHLCD_CREATOR_H_INCLUDED
+#define CX_CHLCD_CREATOR_H_INCLUDED
+
+#include "chlcd/types.h"
+#include "chlcd/error.h"
+#include "chlcd/display.h"
+#include "chlcd/connector.h"
+
+chlcd_error_t chlcd_hd44780_direct_create(
+    chlcd_display_t *self,
+    chlcd_hd44780_direct_connector_t *connector,
+    chlcd_size_t width,
+    chlcd_size_t height
+);
+
+chlcd_error_t chlcd_hd44780_shift_register_create(
+    chlcd_display_t *self,
+    chlcd_hd44780_shift_register_connector_t *connector,
+    chlcd_size_t width,
+    chlcd_size_t height
+);
+
+#endif

+ 17 - 0
include/cx/chlcd/decoder.h

@@ -0,0 +1,17 @@
+#ifndef CX_CHLCD_DECODER_H_INCLUDED
+#define CX_CHLCD_DECODER_H_INCLUDED
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "chlcd/error.h"
+#include "chlcd/command.h"
+#include "chlcd/types.h"
+
+chlcd_error_t chlcd_hd44780_decoder_(
+    chlcd_command_t command,
+    chlcd_data_t content,
+    chlcd_sender_t sender
+);
+
+#endif

+ 20 - 0
include/cx/chlcd/display.h

@@ -0,0 +1,20 @@
+#ifndef CX_CHLCD_DISPLAY_H_INCLUDED
+#define CX_CHLCD_DISPLAY_H_INCLUDED
+
+#include <stdint.h>
+#include <stddef.h>
+#include <stdbool.h>
+
+#include "chlcd/types.h"
+#include "chldc/connector.h"
+#include "chldc/display_type.h"
+
+typedef struct chlcd_display_s {
+    chlcd_sender_t sender;
+    chlcd_decoder_t decoder;
+    chlcd_size_t width;
+    chlcd_size_t height;
+    void *connector;
+} chlcd_display_t;
+
+#endif

+ 9 - 0
include/cx/chlcd/error.h

@@ -0,0 +1,9 @@
+#ifndef CX_CHLCD_ERROR_H_INCLUDED
+#define CX_CHLCD_ERROR_H_INCLUDED
+
+typedef enum chlcd_error_e {
+    CHLCD_SUCCESS,
+    CHLCD_BAD_ARGUMENT
+} chlcd_error_t;
+
+#endif

+ 0 - 0
include/cx/chlcd/hd44780.h


+ 21 - 0
include/cx/chlcd/sender.h

@@ -0,0 +1,21 @@
+#ifndef CX_CHLCD_SENDER_H_INCLUDED
+#define CX_CHLCD_SENDER_H_INCLUDED
+
+#include "chlcd/types.h"
+#include "chlcd/error.h"
+
+chlcd_error_t chlcd_hd44780_direct_sender(
+    void *self,
+    chlcd_data_t content,
+    bool is_command,
+    bool is_half_word
+);
+
+chlcd_error_t chlcd_hd44780_shift_register_sender(
+    void *self,
+    chlcd_data_t content,
+    bool is_command,
+    bool is_half_word
+);
+
+#endif

+ 0 - 0
include/cx/chlcd/shift_register.h


+ 36 - 0
include/cx/chlcd/types.h

@@ -0,0 +1,36 @@
+#ifndef CX_CHLCD_TYPES_H_INCLUDED
+#define CX_CHLCD_TYPES_H_INCLUDED
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#ifdef CHLCD_ON_ESP
+#define chlcd_pin_t gpio_num_t
+#endif
+
+#ifndef chlcd_pin_t 
+#define chlcd_pin_t uint32_t
+#endif
+
+typedef uint8_t chlcd_size_t;
+typedef uint8_t chlcd_bitcount_t;
+struct chlcd_display_s;
+struct chlcd_connector_s;
+enum chlcd_command_e;
+enum chlcd_error_e;
+typedef uint8_t chlcd_data_t;
+
+typedef enum chlcd_error_e (*chlcd_sender_t)(
+    void *self, 
+    chlcd_data_t content,
+    bool is_command,
+    bool is_half_word
+);
+
+typedef enum chlcd_error_r (*chlcd_decoder_t)(
+    enum chlcd_command_e command,
+    chlcd_data_t content,
+    chlcd_sender_t sender
+);
+
+#endif