lcd_out at (x,y) ?

HomeForumsMonoBrick EV3 Firmwarelcd_out at (x,y) ?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #4358
    Author Image
    Helmut Wunder
    Participant

    in 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) ?

    #4366
    Author Image
    Anders Søborg
    Keymaster

    Hi Helmut

    Try to have a look at the LCD example here

    Anders

    #4367
    Author Image
    Helmut Wunder
    Participant

    puuuh.. 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)… 🙁

    #4368
    Author Image
    Anders Søborg
    Keymaster

    Hi 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

    #4369
    Author Image
    Anders Søborg
    Keymaster

    Hi 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

    #4370
    Author Image
    Helmut Wunder
    Participant

    Hi 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.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

Posted in

Make a donation