n3310.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #if !defined(_N3310_H_)
  3. #define _N3310_H_
  4. #include "stm32f10x.h"
  5. /*--------------------------------------------------------------------------------------------------
  6. General purpose constants
  7. --------------------------------------------------------------------------------------------------*/
  8. #define LCD_DC_PIN 12
  9. #define LCD_IN_PIN 13
  10. #define LCD_CLK_PIN 14
  11. #define LCD_RST_PIN 15
  12. #define LCD_DELAY { int i=16; while(i) {__NOP(); i--;}; }
  13. typedef enum
  14. {
  15. LCD_CMD = 0,
  16. LCD_DATA = 1
  17. } LcdCmdData;
  18. void LcdSend ( uint8_t data, LcdCmdData cd );
  19. /*--------------------------------------------------------------------------------------------------
  20. Public function prototypes
  21. --------------------------------------------------------------------------------------------------*/
  22. void LcdInit ( uint8_t Contrast );
  23. #define X_POSITION 0x0100
  24. #define Y_POSITION 0x1000
  25. #define BIG_UP 0x8000
  26. #define BIG_DOWN 0x0080
  27. #define INVERSE 0x80000000
  28. #define X_OFFSET 0x00010000
  29. /*--------------------------------------------------------------------------------------------------
  30. Name : LcdChr
  31. Argument(s) : Ctrl = X*X_MUL+y*Y_MUL+ BIG1 + BIG2 + OutLen
  32. Inverse == 1 - inverse output
  33. Str - out string
  34. Description : Displays a character at current cursor location and increment cursor location.
  35. Len from 0 to 84
  36. y from 0 to 5
  37. x from 0 to 13
  38. BIG_UP - upper part of 16 point string
  39. BIG_DOWN -lower part of 16 point string
  40. BIG_UP | Y2 | Y1 | Y0 | X3 | X2 | X1 | X0
  41. BIG_DOWN | L6 | L5 | L4 | L3 | L2 | L1 | L0
  42. It is parts of Ctrl. Ctrl = X_MUL*X+Y_MUL*Y+LENGTH+(BIG_UP||BIG_DOWN||0)
  43. Length should be >= strlen(Str).
  44. Example:LcdChr(5*X_MUL+3*Y_MUL+8, 1, "123") - will out string 123 in position 6 row 4 8 points font.
  45. The 5 symbols afrer 123 will be cleaned ( 8 - strlen("123"))
  46. Return value : None.
  47. --------------------------------------------------------------------------------------------------*/
  48. void LcdChr ( uint32_t Ctrl, const char* Str );
  49. /* LcdChr ( Y_POSITION*2+X_POSITION*1+13+INVERSE+X_OFFSET*3, "Hello world" );*/
  50. void LcdClear(void);
  51. void LcdContrast ( uint8_t Contrast );
  52. void LcdGotoXY(uint8_t X, uint8_t Y);
  53. #endif // _N3310_H_
  54. /*--------------------------------------------------------------------------------------------------
  55. End of file.
  56. --------------------------------------------------------------------------------------------------*/