aboutsummaryrefslogtreecommitdiff
path: root/src/core/Print.cpp
diff options
context:
space:
mode:
authorlynxeyed-atsu <lynxeyed@xj9.so-net.ne.jp>2012-09-25 21:32:32 +0900
committerlynxeyed-atsu <lynxeyed@xj9.so-net.ne.jp>2012-09-25 21:32:32 +0900
commit5c9eb1b24ed4cfa7eae59ffbc24bdbbce814ba35 (patch)
tree621f90d90f4a046136411c75b3ebc4889b640f23 /src/core/Print.cpp
parentedb6aabe187a08cb67947fcfce13fefd26e42bb6 (diff)
apply a patch made by audin to a src/coreHEADmaster
audin fixed some bugs about Print class and gpio function with interruption for us. thank you!
Diffstat (limited to 'src/core/Print.cpp')
-rwxr-xr-xsrc/core/Print.cpp252
1 files changed, 128 insertions, 124 deletions
diff --git a/src/core/Print.cpp b/src/core/Print.cpp
index b26848f..e259ac4 100755
--- a/src/core/Print.cpp
+++ b/src/core/Print.cpp
@@ -1,124 +1,128 @@
-#include "Print.h"
-
-void Print::print(const char *s) //uart_puts
-{
- int n;
- for (n = 0; *s; s++, n++) {
- write(*s);
- }
- //return n;
- return;
-}
-
-void Print::print(int val, RADIX_FORMAT format)
-{
- if(format == BYTE)
- {
- write((char)(val & 0xff));
- return;
- }
- char s[33];
- int i,j;
- i=j=0; // header of strings
- if (val<0)
- { //minus value
- s[i]='-';
- val=~val+1;
- i++;
- j++;
- }
- switch(format)
- {
- case BIN:
- while (val>0)
- { // do until zero
- s[i++]=radix_bin[val%format];
- val/=format;
- }
- break;
-
- case OCT:
- while (val>0)
- { // do until zero
- s[i++]=radix_oct[val%format];
- val/=format;
- }
- break;
-
- case DEC: //RADIX = Decimal
- while (val>0)
- { // do until zero
- s[i++]=radix_dec[val%format];
- val/=format;
- }
- break;
-
- case HEX: //RADIX = Hexadecimal
- while (val>0)
- { // do until zero
- s[i++]=radix_hex[val%format];
- val/=format;
- }
- break;
- default:
- break;
- }
- s[i--]='\0'; // EOF
- while (j<i)
- { // reverse strings array
- char t;
- t=s[j]; s[j]=s[i]; s[i]=t;
- j++; i--;
- }
- print(s);
-
- return ;
-}
-
-void Print::write(const char *s, int length)
-{
- int n;
- for(n=0;n<length;s++,n++)
- {
- write(*s);
- }
- return;
-}
-
-void Print::println(const char *s)
-{
- print(s);
- println();
- return;
-}
-
-
-void Print::println(int val, RADIX_FORMAT format)
-{
- print(val,format);
- println();
- return;
-}
-
-void Print::println(void)
-{
- write ('\r');
- write ('\n');
- return;
-}
-
-void Print::print(const char c)
-{
- write(c);
- return;
-}
-
-void Print::println(const char c)
-{
- write(c);
- println();
- return;
-}
-
-
-
+#include "Print.h"
+
+void Print::print(const char *s) //uart_puts
+{
+ int n;
+ for (n = 0; *s; s++, n++) {
+ write(*s);
+ }
+ //return n;
+ return;
+}
+
+void Print::print(int val, RADIX_FORMAT format)
+{
+ if( val == 0){
+ write('0');
+ return;
+ }
+ if(format == BYTE)
+ {
+ write((char)(val & 0xff));
+ return;
+ }
+ char s[33];
+ int i,j;
+ i=j=0; // header of strings
+ if (val<0)
+ { //minus value
+ s[i]='-';
+ val=~val+1;
+ i++;
+ j++;
+ }
+ switch(format)
+ {
+ case BIN:
+ while (val>0)
+ { // do until zero
+ s[i++]=radix_bin[val%format];
+ val/=format;
+ }
+ break;
+
+ case OCT:
+ while (val>0)
+ { // do until zero
+ s[i++]=radix_oct[val%format];
+ val/=format;
+ }
+ break;
+
+ case DEC: //RADIX = Decimal
+ while (val>0)
+ { // do until zero
+ s[i++]=radix_dec[val%format];
+ val/=format;
+ }
+ break;
+
+ case HEX: //RADIX = Hexadecimal
+ while (val>0)
+ { // do until zero
+ s[i++]=radix_hex[val%format];
+ val/=format;
+ }
+ break;
+ default:
+ break;
+ }
+ s[i--]='\0'; // EOF
+ while (j<i)
+ { // reverse strings array
+ char t;
+ t=s[j]; s[j]=s[i]; s[i]=t;
+ j++; i--;
+ }
+ print(s);
+
+ return ;
+}
+
+void Print::write(const char *s, int length)
+{
+ int n;
+ for(n=0;n<length;s++,n++)
+ {
+ write(*s);
+ }
+ return;
+}
+
+void Print::println(const char *s)
+{
+ print(s);
+ println();
+ return;
+}
+
+
+void Print::println(int val, RADIX_FORMAT format)
+{
+ print(val,format);
+ println();
+ return;
+}
+
+void Print::println(void)
+{
+ write ('\r');
+ write ('\n');
+ return;
+}
+
+void Print::print(const char c)
+{
+ write(c);
+ return;
+}
+
+void Print::println(const char c)
+{
+ write(c);
+ println();
+ return;
+}
+
+
+