Revision 5:1c78c0b4f513, committed 2011-02-06
- Comitter:
- Midimetric
- Date:
- Sun Feb 06 13:30:28 2011 +0000
- Parent:
- 4:545e25d4c3d8
- Commit message:
Changed in this revision
--- a/doggy.cpp Sat Jan 08 16:27:12 2011 +0000
+++ b/doggy.cpp Sun Feb 06 13:30:28 2011 +0000
@@ -4,7 +4,8 @@
{
//b_ = (char*)calloc( 1024, 1 );
XFont = xfont_8;
-
+ b_ = w_;
+ Clear();
const unsigned char c[] = {
0x40, // display start line + 0-63
0xa1, // ADC set 0xA1 + 0 = normal (for reverse view) / +1 = reverse (for normal view)
--- a/doggy.h Sat Jan 08 16:27:12 2011 +0000
+++ b/doggy.h Sun Feb 06 13:30:28 2011 +0000
@@ -188,7 +188,15 @@
/// @param y1 bottom coordinate from 0 to 63 included
/// @param op bit math operation (raster), values { poke (default), wipe, inv }
void LineV( int x, int y0, int y1, doggy_op op = poke );
-
+
+ /// Draw an diagonal line
+ ///
+ /// @param x0 start horizontal coordinate from 0 to 127 included
+ /// @param y0 start vertical coordinate from 0 to 63 included
+ /// @param x1 end horizontal coordinate from 0 to 127 included
+ /// @param y1 end vertical coordinate from 0 to 63 included
+ void Line( int x0, int y0, int x1, int y1, doggy_op = poke );
+
/// Draw an empty rectangle by combining 2 LineH and 2 LineV calls
///
/// @param x0 top left corner, horizontal coordinate from 0 to 127 included
@@ -247,7 +255,7 @@
///
/// New line: string can contain the new line '\\n' or (13)
///
- /// Wrapping: if the ouput reaches the right side of the screen, it will wrap to next line at position x=0.
+ /// Wrapping: if the ouput reaches the right side of the screen, it will wrap to next line at position x.
/// wrapping is not space dependant, it happens anywhere in the string (inside words)
/// if wrapped line happens to begins with a space, the space is skipped
///
@@ -258,6 +266,8 @@
///
/// @return the last y coordinate used to output chars (may be different than initial argument if string was wrapped)
int XString( int x, int y, const char* s, doggy_op op = poke );
+ int XString( int x, int y, int i, doggy_op = poke );
+ int XString( int x, int y, float f, doggy_op = poke );
};
/// Type definition for RasterOp
--- a/draw2D.cpp Sat Jan 08 16:27:12 2011 +0000
+++ b/draw2D.cpp Sun Feb 06 13:30:28 2011 +0000
@@ -38,6 +38,37 @@
for( int y = y0 ; y <= y1 ; y++ )
(this->*op)( x, y );
}
+void DogMLCD::Line( int x0, int y0, int x1, int y1, doggy_op raster )
+{
+ bool steep = abs( y1 - y0 ) > abs( x1 - x0 );
+ if( steep ) { SWAP( x0, y0 ) SWAP( x1, y1 ) }
+ if( x0 > x1) { SWAP( x0, x1 ) SWAP( y0, y1 ) }
+
+ int dx = x1 - x0;
+ int dy = abs( y1 - y0 );
+ int e = dx / 2;
+ int ystep = y0 < y1 ? 1 : -1;
+ RasterOp op = ((RasterOp[]){ &DogMLCD::Poke, &DogMLCD::Wipe, &DogMLCD::Inv })[raster];
+
+ if( steep ) for( int x = x0, y = y0 ; x <= x1 ; x++ )
+ {
+ (this->*op)( y, x );
+ if( ( e -= dy ) < 0 )
+ {
+ y += ystep;
+ e += dx;
+ }
+ }
+ else for( int x = x0, y = y0 ; x <= x1 ; x++ )
+ {
+ (this->*op)( x, y );
+ if( ( e -= dy ) < 0 )
+ {
+ y += ystep;
+ e += dx;
+ }
+ }
+}
void DogMLCD::Frame( int x0, int y0, int x1, int y1, doggy_op raster )
{
ORDER( x0, x1 )
--- a/globaldefs.h Sat Jan 08 16:27:12 2011 +0000
+++ b/globaldefs.h Sun Feb 06 13:30:28 2011 +0000
@@ -6,12 +6,15 @@
// Wait time after changing state of A0 in uS
#define DOGMLCD_TIME 8
+#ifndef BOUND
+ #define BOUND(a,b,c) if( a < b ) a = b; else if( a > c ) a = c;
+#endif
+#ifndef SWAP
+ #define SWAP(a,b) { int c = a; a = b; b = c; }
+#endif
#ifndef ORDER
#define ORDER(a,b) if( a > b ) { int c = a; a = b; b = c; }
#endif
-#ifndef BOUND
- #define BOUND(a,b,c) if( a < b ) a = b; else if( a > c ) a = c;
-#endif
const unsigned char DOGMLCD_on[] = { 1, 2, 4, 8, 16, 32, 64, 128 };
const unsigned char DOGMLCD_off[]= { 254, 253, 251, 247, 239, 223, 191, 127 };
--- a/xchar.cpp Sat Jan 08 16:27:12 2011 +0000
+++ b/xchar.cpp Sun Feb 06 13:30:28 2011 +0000
@@ -29,6 +29,18 @@
x++;
}
}
+int DogMLCD::XString( int x, int y, int i, doggy_op raster )
+{
+ char buf[32];
+ sprintf( buf, "%d", i );
+ return XString( x, y, buf, raster );
+}
+int DogMLCD::XString( int x, int y, float f, doggy_op raster )
+{
+ char buf[32];
+ sprintf( buf, "%f", f );
+ return XString( x, y, buf, raster );
+}
int DogMLCD::XString( int x, int y, const char* s, doggy_op raster )
{
int oldx = x;