simpletext library  v0.99
Compact variations of put/get write/read and print/scan for smaller program sizes
simpletext.h
Go to the documentation of this file.
1 
46 #ifndef __SimpleTEXT__
47 #define __SimpleTEXT__
48 
49 #include <propeller.h>
50 
51 #ifdef __cplusplus
52 extern "C"
53 {
54 #endif
55 
56 #if !defined(__PROPELLER_32BIT_DOUBLES__)
57 #error "This library requires 32bit doubles"
58 #endif
59 
61 #define TERM_NAME_LEN 20
62 #define TERM_COG_LEN 7
63 
64 
68 typedef struct text_struct
69 {
71  int (*rxChar)(struct text_struct *p);
73  int (*txChar)(struct text_struct *p, int ch);
75  int cogid[TERM_COG_LEN];
77  volatile void *devst;
78 } text_t;
79 
81 #define getStopCOGID(id) ((id)-(1))
82 #define setStopCOGID(id) ((id)+(1))
83 
84 
88 #include "serial.h"
89 
90 /* Values for use with SimpleIDE Terminal */
91 #ifndef HOME
92 
96 #define HOME (1)
97 #endif
98 
99 #ifndef CRSRXY
100 
106 #define CRSRXY (2)
107 #endif
108 
109 #ifndef CRSRLF
110 
114 #define CRSRLF (3)
115 #endif
116 
117 #ifndef CRSRRT
118 
122 #define CRSRRT (4)
123 #endif
124 
125 #ifndef CRSRUP
126 
130 #define CRSRUP (5)
131 #endif
132 
133 #ifndef CRSRDN
134 
138 #define CRSRDN (6)
139 #endif
140 
141 #ifndef BEEP
142 
146 #define BEEP (7)
147 #endif
148 
149 #ifndef BKSP
150 
155 #define BKSP (8)
156 #endif
157 
158 #ifndef TAB
159 
163 #define TAB (9)
164 #endif
165 
166 #ifndef NL
167 
171 #define NL (10)
172 #endif
173 
174 #ifndef LF
175 
178 #define LF (10)
179 #endif
180 
181 #ifndef CLREOL
182 
186 #define CLREOL (11)
187 #endif
188 
189 #ifndef CLRDN
190 
194 #define CLRDN (12)
195 #endif
196 
197 #ifndef CR
198 
202 #define CR (13)
203 #endif
204 
205 #ifndef CRSRX
206 
210 #define CRSRX (14)
211 #endif
212 
213 #ifndef CRSRY
214 
218 #define CRSRY (15)
219 #endif
220 
221 #ifndef CLS
222 
226 #define CLS (16)
227 #endif
228 
229 
230 typedef text_t terminal;
231 
232 
273 int print(const char *format, ...) __attribute__((format (printf, 1, 2)));
274 
275 
316 int scan(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
317 
318 
333 int sprint(char *buffer, const char *format, ...) __attribute__((format (printf, 2, 3)));
334 
335 
349 int sscan(const char *buffer, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
350 
351 
373 int dprint(text_t* device, const char *format, ...) __attribute__((format (printf, 2, 3)));
374 
375 
391 int dscan(text_t* device, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
392 
393 
414 int printi(const char *format, ...) __attribute__((format (printf, 1, 2)));
415 
416 
430 int scani(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
431 
432 
450 int dprinti(text_t* device, const char *format, ...) __attribute__((format (printf, 2, 3)));
451 
452 
469 int dscani(text_t* device, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
470 
471 
487 int sprinti(char *buffer, const char *format, ...) __attribute__((format (printf, 2, 3)));
488 
489 
504 int sscani(const char *buffer, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
505 
506 
518 void putChar(char c);
519 
520 
526 int putStr(const char* str);
527 
528 
534 void putDec(int value);
535 
536 
543 void putFloat(float value);
544 
545 
551 void putBin(int value);
552 
553 
560 void putHex(int value);
561 
562 
570 int putStrLen(char* str, int width);
571 
572 
580 void putDecLen(int value, int width);
581 
582 
593 void putFloatPrecision(float value, int width, int precision);
594 
595 
604 void putBinLen(int value, int digits);
605 
606 
615 void putHexLen(int value, int digits);
616 
617 
623 int putln(const char* str);
624 
625 
632 int putLine(const char* str);
633 
634 
648 int getBin(void);
649 
650 
656 int getChar(void);
657 
658 
664 int getDec(void);
665 
666 
672 float getFloat(void);
673 
674 
680 int getHex(void);
681 
682 
693 char *getStr(char *buffer, int max);
694 
695 
712 void writeChar(text_t *device, char c);
713 
714 
723 int writeStr(text_t *device, char* str);
724 
725 
734 void writeDec(text_t *device, int value);
735 
736 
746 void writeFloat(text_t *device, float value);
747 
748 
758 void writeBin(text_t *device, int value);
759 
760 
770 void writeHex(text_t *device, int value);
771 
772 
783 int writeStrLen(text_t *device, char* str, int width);
784 
785 
797 void writeDecLen(text_t *device, int value, int width);
798 
799 
813 void writeFloatPrecision(text_t *device, float value, int width, int precision);
814 
815 
827 void writeBinLen(text_t *device, int value, int digits);
828 
829 
841 void writeHexLen(text_t *device, int value, int digits);
842 
843 
852 int writeLine(text_t *device, char* str);
853 
854 
871 int readChar(text_t *device);
872 
873 
886 char *readStr(text_t *device, char *buffer, int max);
887 
888 
897 int readDec(text_t *device);
898 
899 
908 float readFloat(text_t *device);
909 
910 
919 int readBin(text_t *device);
920 
921 
930 int readHex(text_t *device);
931 
932 
949 terminal *simpleterm_open(void);
950 
956 void simpleterm_close(void);
957 
978 terminal *simpleterm_reopen(int rxpin, int txpin, int mode, int baud);
979 
988 static inline void simpleterm_set(text_t *ptr)
989 {
990  extern text_t *dport_ptr;
991  simpleterm_close();
992  dport_ptr = ptr;
993 }
994 
1000 terminal *simpleterm_pointer(void);
1001 
1002 
1008  /*
1009  * @cond
1010  * API not intended for public use
1011  */
1012 int printNumber(text_t *p, unsigned long u, int base, int width, int fill_char);
1013 char* _safe_gets(text_t *term, char* origBuf, int count);
1014 const char* _scanf_getf(const char *str, float* dst);
1015 const char* _scanf_getl(const char *str, int* dst, int base, unsigned width, int isSigned);
1016 
1017 int SPUTC(int c, char *buf);
1018 int SPUTS(char *s, char *obuf);
1019 int SPUTL(unsigned long u, int base, int width, int fill_char, char *obuf);
1020 
1021 #include <stdarg.h>
1022 int _doscanf(const char* str, const char *fmt, va_list args);
1023 int _intscanf(const char* str, const char *fmt, va_list args);
1024 int _dosprnt(const char *fmt, va_list args, char *obuf);
1025 int _intsprnt(const char *fmt, va_list args, char *obuf);
1026 
1027 char* float2string(float f, char *s, int width, int precision);
1028 float string2float(char *s, char **end);
1029 
1030  /*
1031  * @endcond
1032  * API not intended for public use
1033  */
1034 
1035 #ifdef __cplusplus
1036 }
1037 #endif
1038 
1039 #endif
1040 /* __SimpleTEXT__ */
1041 
1042