EPPL example libraries  0.1 alpha
 All Files Functions Variables Groups Pages
alcddrv.h
Go to the documentation of this file.
1 #ifndef ALCDDRV_H_INCLUDED
2 #define ALCDDRV_H_INCLUDED
3 
13 #include <stdint.h>
14 #include "alcddrv_config.h"
15 #include "alcddrv_cmd.h"
16 #include "eppl.h"
17 
206 /* Default pins configuration (not present) */
207 #ifndef ALCD_RS
208  #define ALCD_RS EPPL_NP
209 #endif
210 #ifndef ALCD_RW
211  #define ALCD_RW EPPL_NP
212 #endif
213 #ifndef ALCD_E
214  #define ALCD_E EPPL_NP
215 #endif
216 #ifndef ALCD_D0
217  #define ALCD_D0 EPPL_NP
218 #endif
219 #ifndef ALCD_D1
220  #define ALCD_D1 EPPL_NP
221 #endif
222 #ifndef ALCD_D2
223  #define ALCD_D2 EPPL_NP
224 #endif
225 #ifndef ALCD_D3
226  #define ALCD_D3 EPPL_NP
227 #endif
228 #ifndef ALCD_D4
229  #define ALCD_D4 EPPL_NP
230 #endif
231 #ifndef ALCD_D5
232  #define ALCD_D5 EPPL_NP
233 #endif
234 #ifndef ALCD_D6
235  #define ALCD_D6 EPPL_NP
236 #endif
237 #ifndef ALCD_D7
238  #define ALCD_D7 EPPL_NP
239 #endif
240 
241 /* Default display size */
242 #ifndef ALCD_SX
243  #warning No SX diamension of ALCD defined - using default value.
244  #define ALCD_SX 16
245 #endif
246 /* Default display size */
247 #ifndef ALCD_SY
248  #warning No SY diamension of ALCD defined - using default value.
249  #define ALCD_SY 2
250 #endif
251 
266 #define ALCD_PINCONFIG \
267  EPPL_SC(ALCD_D7, ALCD_DOutMode | EPPL_outSet_0),\
268  EPPL_SC(ALCD_D6, ALCD_DOutMode | EPPL_outSet_0),\
269  EPPL_SC(ALCD_D5, ALCD_DOutMode | EPPL_outSet_0),\
270  EPPL_SC(ALCD_D4, ALCD_DOutMode | EPPL_outSet_0),\
271  EPPL_SC(ALCD_D3, ALCD_DOutMode | EPPL_outSet_0),\
272  EPPL_SC(ALCD_D2, ALCD_DOutMode | EPPL_outSet_0),\
273  EPPL_SC(ALCD_D1, ALCD_DOutMode | EPPL_outSet_0),\
274  EPPL_SC(ALCD_D0, ALCD_DOutMode | EPPL_outSet_0),\
275  EPPL_SC(ALCD_RW, ALCD_CtrlMode | EPPL_outSet_0),\
276  EPPL_SC(ALCD_RS, ALCD_CtrlMode | EPPL_outSet_0),\
277  EPPL_SC(ALCD_E, ALCD_CtrlMode | EPPL_outSet_0)
278 
288 #define ALCD_PIN_DEFINED(p) ((p) != EPPL_NP)
289 
296 #define ALCD_CANREAD ALCD_PIN_DEFINED(ALCD_RW)
297 
309 void alcd_cmd(uint8_t cmd);
310 
320 void alcd_data(uint8_t data);
321 
333 char alcd_rdata(void);
334 
345 void alcd_init(void);
346 
353 void alcd_puts(const char *pstr);
354 
363 void alcd_read(char *pstr, uint8_t size);
364 
371 void alcd_puts_P(const __flash char *pstr);
372 
381 void alcd_defineChar(char c, const char *ppat);
382 
391 void alcd_defineChar_P(char c, const __flash char *ppat);
392 
401 void alcd_readDefinedChar(char c, char *ppat);
402 
412 static inline void alcd_cls(void)
413 {
415 }
416 
423 static inline void alcd_home(void)
424 {
426 }
427 
436 static inline void alcd_turnOnOff(uint8_t display, uint8_t cursor, uint8_t blink)
437 {
439  (display ? ALCD_CMD_On_Display : 0) |
440  (cursor ? ALCD_CMD_On_Cursor : 0) |
441  (blink ? ALCD_CMD_On_Blink : 0)
442  );
443 }
444 
452 static inline void alcd_shift(uint8_t right_left, uint8_t display_cursor)
453 {
455  (right_left ? ALCD_CMD_Shift_Left : ALCD_CMD_Shift_Right) |
456  (display_cursor ? ALCD_CMD_Shift_Display : ALCD_CMD_Shift_Cursor)
457  );
458 }
459 
469 static inline void alcd_entryMode(uint8_t inc_dec, uint8_t shift)
470 {
473  (shift ? ALCD_CMD_Mode_DisplayShift : 0)
474  );
475 }
476 
484 static inline void alcd_goto(uint8_t y, uint8_t x)
485 {
486  uint8_t pos = x;
487 
488  if(1 < ALCD_SY)
489  {
490  if(0 != (y & 1))
491  pos += ALCD_SecondLineAddr;
492  if(2 < ALCD_SY)
493  {
494  if(0 != (y & 2))
495  pos += ALCD_SX;
496  }
497  }
499 }
500 
507 static inline void alcd_putc(char c)
508 {
509  alcd_data(c);
510 }
511 
518 static inline char alcd_getc(void)
519 {
520  return alcd_rdata();
521 }
522 
524 #endif /* ALCDDRV_H_INCLUDED */