simpletext library  v0.99.1
Compact variations of put/get write/read and print/scan for smaller program sizes
simpletext.h
Go to the documentation of this file.
1 
48 #ifndef __SimpleTEXT__
49 #define __SimpleTEXT__
50 
51 #include <propeller.h>
52 
53 #ifdef __cplusplus
54 extern "C"
55 {
56 #endif
57 
58 #if !defined(__PROPELLER_32BIT_DOUBLES__)
59 #error "This library requires 32bit doubles"
60 #endif
61 
63 #define TERM_NAME_LEN 20
64 #define TERM_COG_LEN 7
65 
66 
70 typedef struct text_struct
71 {
73  int (*rxChar)(struct text_struct *p);
75  int (*txChar)(struct text_struct *p, int ch);
77  int cogid[TERM_COG_LEN];
79  volatile void *devst;
80 } text_t;
81 
83 #define getStopCOGID(id) ((id)-(1))
84 #define setStopCOGID(id) ((id)+(1))
85 
86 
90 #include "serial.h"
91 
92 /* Values for use with SimpleIDE Terminal */
93 #ifndef HOME
94 
98 #define HOME (1)
99 #endif
100 
101 #ifndef CRSRXY
102 
108 #define CRSRXY (2)
109 #endif
110 
111 #ifndef CRSRLF
112 
116 #define CRSRLF (3)
117 #endif
118 
119 #ifndef CRSRRT
120 
124 #define CRSRRT (4)
125 #endif
126 
127 #ifndef CRSRUP
128 
132 #define CRSRUP (5)
133 #endif
134 
135 #ifndef CRSRDN
136 
140 #define CRSRDN (6)
141 #endif
142 
143 #ifndef BEEP
144 
148 #define BEEP (7)
149 #endif
150 
151 #ifndef BKSP
152 
157 #define BKSP (8)
158 #endif
159 
160 #ifndef TAB
161 
165 #define TAB (9)
166 #endif
167 
168 #ifndef NL
169 
173 #define NL (10)
174 #endif
175 
176 #ifndef LF
177 
180 #define LF (10)
181 #endif
182 
183 #ifndef CLREOL
184 
188 #define CLREOL (11)
189 #endif
190 
191 #ifndef CLRDN
192 
196 #define CLRDN (12)
197 #endif
198 
199 #ifndef CR
200 
204 #define CR (13)
205 #endif
206 
207 #ifndef CRSRX
208 
212 #define CRSRX (14)
213 #endif
214 
215 #ifndef CRSRY
216 
220 #define CRSRY (15)
221 #endif
222 
223 #ifndef CLS
224 
228 #define CLS (16)
229 #endif
230 
231 
232 typedef text_t terminal;
233 
234 
275 int print(const char *format, ...) __attribute__((format (printf, 1, 2)));
276 
277 
318 int scan(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
319 
320 
335 int sprint(char *buffer, const char *format, ...) __attribute__((format (printf, 2, 3)));
336 
337 
351 int sscan(const char *buffer, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
352 
353 
375 int dprint(text_t* device, const char *format, ...) __attribute__((format (printf, 2, 3)));
376 
377 
393 int dscan(text_t* device, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
394 
395 
416 int printi(const char *format, ...) __attribute__((format (printf, 1, 2)));
417 
418 
432 int scani(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
433 
434 
452 int dprinti(text_t* device, const char *format, ...) __attribute__((format (printf, 2, 3)));
453 
454 
471 int dscani(text_t* device, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
472 
473 
489 int sprinti(char *buffer, const char *format, ...) __attribute__((format (printf, 2, 3)));
490 
491 
506 int sscani(const char *buffer, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
507 
508 
520 void putChar(char c);
521 
522 
528 int putStr(const char* str);
529 
530 
536 void putDec(int value);
537 
538 
545 void putFloat(float value);
546 
547 
553 void putBin(int value);
554 
555 
562 void putHex(int value);
563 
564 
572 int putStrLen(char* str, int width);
573 
574 
582 void putDecLen(int value, int width);
583 
584 
595 void putFloatPrecision(float value, int width, int precision);
596 
597 
606 void putBinLen(int value, int digits);
607 
608 
617 void putHexLen(int value, int digits);
618 
619 
625 int putln(const char* str);
626 
627 
634 int putLine(const char* str);
635 
636 
650 int getBin(void);
651 
652 
658 int getChar(void);
659 
660 
666 int getDec(void);
667 
668 
674 float getFloat(void);
675 
676 
682 int getHex(void);
683 
684 
695 char *getStr(char *buffer, int max);
696 
697 
714 void writeChar(text_t *device, char c);
715 
716 
725 int writeStr(text_t *device, char* str);
726 
727 
736 void writeDec(text_t *device, int value);
737 
738 
748 void writeFloat(text_t *device, float value);
749 
750 
760 void writeBin(text_t *device, int value);
761 
762 
772 void writeHex(text_t *device, int value);
773 
774 
785 int writeStrLen(text_t *device, char* str, int width);
786 
787 
799 void writeDecLen(text_t *device, int value, int width);
800 
801 
815 void writeFloatPrecision(text_t *device, float value, int width, int precision);
816 
817 
829 void writeBinLen(text_t *device, int value, int digits);
830 
831 
843 void writeHexLen(text_t *device, int value, int digits);
844 
845 
854 int writeLine(text_t *device, char* str);
855 
856 
873 int readChar(text_t *device);
874 
875 
888 char *readStr(text_t *device, char *buffer, int max);
889 
890 
899 int readDec(text_t *device);
900 
901 
910 float readFloat(text_t *device);
911 
912 
921 int readBin(text_t *device);
922 
923 
932 int readHex(text_t *device);
933 
934 
951 terminal *simpleterm_open(void);
952 
958 void simpleterm_close(void);
959 
980 terminal *simpleterm_reopen(int rxpin, int txpin, int mode, int baud);
981 
990 static inline void simpleterm_set(text_t *ptr)
991 {
992  extern text_t *dport_ptr;
993  simpleterm_close();
994  dport_ptr = ptr;
995 }
996 
1002 terminal *simpleterm_pointer(void);
1003 
1004 
1010  /*
1011  * @cond
1012  * API not intended for public use
1013  */
1014 int printNumber(text_t *p, unsigned long u, int base, int width, int fill_char);
1015 char* _safe_gets(text_t *term, char* origBuf, int count);
1016 const char* _scanf_getf(const char *str, float* dst);
1017 const char* _scanf_getl(const char *str, int* dst, int base, unsigned width, int isSigned);
1018 
1019 int SPUTC(int c, char *buf);
1020 int SPUTS(char *s, char *obuf);
1021 int SPUTL(unsigned long u, int base, int width, int fill_char, char *obuf);
1022 
1023 #include <stdarg.h>
1024 int _doscanf(const char* str, const char *fmt, va_list args);
1025 int _intscanf(const char* str, const char *fmt, va_list args);
1026 int _dosprnt(const char *fmt, va_list args, char *obuf);
1027 int _intsprnt(const char *fmt, va_list args, char *obuf);
1028 
1029 char* float2string(float f, char *s, int width, int precision);
1030 float string2float(char *s, char **end);
1031 
1032  /*
1033  * @endcond
1034  * API not intended for public use
1035  */
1036 
1037 #ifdef __cplusplus
1038 }
1039 #endif
1040 
1041 #endif
1042 /* __SimpleTEXT__ */
1043 
1044