Home→Forums→MonoBrick EV3 Firmware→lcd_out at (x,y) ?
- This topic has 5 replies, 2 voices, and was last updated 10 years, 7 months ago by Helmut Wunder.
-
AuthorPosts
-
May 18, 2014 at 10:57 #4358
Helmut WunderParticipantin my program
using System; using MonoBrickFirmware; using MonoBrickFirmware.Display; namespace HelloWorld { class MainClass { public static void Main(string[] args) { LcdConsole.WriteLine("Hello World!"); System.Threading.Thread.Sleep(10000); } } }
LcdConsole.WriteLine(“Hello World!”); appears at the bottom line.
how is it possible to write to any defined (x,y) postion like NXC TextOut(x,y, string) ?
May 18, 2014 at 18:22 #4366
Anders SøborgKeymasterMay 18, 2014 at 19:06 #4367
Helmut WunderParticipantpuuuh.. rather complicated this new-point-box-offeset-whatever-thing.
A half side of text just for an equivalent to
TextOut(10,24,"Hello World");
?Can’t the coordinates be used by simple numbers or variables?
for (int x=0; x<8; ++x) {NumOut(x, x*10, x);}
or, more C-like, more easy and “universal” formattable
{printfxy(x, x*10, "%2d", x);}
C# seems to need 20 times more letters and lines to write as C (CMIIW)… 🙁
May 18, 2014 at 19:22 #4368
Anders SøborgKeymasterHi Helmut
A half side of text just for an equivalent to TextOut(10,24,”Hello World”) ?
No – this whole program is an example on how to use the LCD. I didn’t say it was an equivalent to a known NXC command.
Like the example shows start by creating a Rectangle and use the WriteTextBox function to write some text. One or two lines depending on how you write the code….
I have not tested this code but something along the lines of…
Rectangle box = new Rectangle( new Point(0,0), new Point(20, 20)); Lcd.Instance.WriteTextBox(Font.MediumFont, box, "Test"); System.Threading.Thread.Sleep(5000); Lcd.Instance.Clear(); Lcd.Instance.WriteText(Font.MediumFont, new Point(0, 30), "Test2");
You can find more info in the MonoBrick firmware documentation
Anders
May 18, 2014 at 19:30 #4369
Anders SøborgKeymasterHi Helmut
I could help but I simply need to comment on this…
C# seems to need 20 times more letters and lines to write as C (CMIIW)… 🙁
It is totally opposite. I dare you to write a C program that let’s you send emails from a EV3 in 65 lines like this example. I don’t think that it can be done…
C# and its huge library will help write more simple and clean code – but you must unlearn what you have leaned 🙂
Anders
May 18, 2014 at 21:10 #4370
Helmut WunderParticipantHi Anders,
for emails you might be right – but I don’t want to send emails, I need quick and straight lcd_out and motor control and sensor reading and calculations about all that without all this new instantiation of classes and objects thing even for every single pure variable in deprivation of simple and straight (global) functions and procedures.
(But I’m sure a C header file can be written which only had to be #included and even emails would be fine for C.)Instead of your code
Rectangle box = new Rectangle( new Point(0,0), new Point(20, 20)); Lcd.Instance.WriteTextBox(Font.MediumFont, box, "Test"); System.Threading.Thread.Sleep(5000); Lcd.Instance.Clear(); Lcd.Instance.WriteText(Font.MediumFont, new Point(0, 30), "Test2");
I would code
draw_rectangle(0,0,20,20); SetFont(MediumFont); printfxy(10,10,"Test"); msleep(5000); cls(); printfxy(0,30,"Test2");
I even could write my simple “write text into a box” function:
void textinbox (int b1,int b2,int b3,int b4, int t1, int t2, string msg) { draw_rectangle(b1,b2,b3,b4); printfxy(b1+t1,b2+t2, msg); } // textinbox (0,0,20,20, 0,30, "Test");// w/o that probably 20kb C# OOP code overhead
I guess my brain is actually thinking in C-like or Pascal-like procedural patterns, and using them I’m able to do quite complex things (AI, self-training neural nets, chess egine programming and this kind of stuff). I’m quite sure I won’t understand this knotty objecturalization any more, and the overcomplicated IDEs are an obstruction on a quite different addditional level which is not my world.
IMO Mono and C# and it’s environments is unfortunately more for professional programmers, not for simple leisure time home programmers- what they needed would be more like NXC or even “Turbo-Pascal for MSDOS” level. OOP is really weird to me. I think I’ll resign, the earlier the better. -
AuthorPosts
You must be logged in to reply to this topic.
Follow