Brick-Simulator?

HomeForumsMonoBrick EV3 FirmwareBrick-Simulator?

Viewing 13 posts - 16 through 28 (of 28 total)
  • Author
    Posts
  • #3859
    Author Image
    Anders Søborg
    Keymaster

    Hi Martin

    I can’t wait to try your program

    Anders

    #3889
    Author Image
    Martin Wagner
    Participant

    Hi Anders,

    My hair turned even more gray. Since my first bitmap approach for the LCD-screen had this spoiled text, I started building a WPF realization with a rectangle per pixel (recommendation of a colleague at work). As WPF-newbie, I really had problems properly implementing the MVVM pattern. But after a lot of pixel-per-pixel-testing it finally worked and I had to realize that was ways too slow.
    So I started with the bitmap approach again. I realized that the spoiled writing is due to reverse bit order in displayBuffer. Why did you implement it this way? After adding a reversing and negating function, I could use the BitmapSource.Create functions from DotNet. The screen finally works okay! Ufff. (See attachment).

    Before implementing the next step, I got a question:
    At the moment, several instances of Lcd could be created, overwriting each other. How shall I solved that?
    1. Make the Lcd-HAL accept inputs from several lcd instances, which are OR-wise combined, with a semaphore controlling access. But then public void Clear() would have to be changed as well.
    2. Convert Lcd into a singleton as well to ensure that only one instance exists. ( Lcd myLcd = new Lcd(); ==>> Lcd myLcd = Lcd.init; )

    I would prefer the second solution. What do you suggest?

    Hope to hear from you soon,
    Martin

    Attachments:
    You must be logged in to view attached files.
    #3892
    Author Image
    Martin Wagner
    Participant

    Hi Anders,
    just tested my modified MonoBrickFirmware-project with Mono 2.10.9: Builds without errors or warnings, EV3 simulator runs okay.
    Good night,
    Martin

    #3896
    Author Image
    Lars Jeppesen
    Keymaster

    Hi Martin,

    My advice is to make one instance of the display and pass the to your screen handling routines.
    If you like you can put it in a singleton, but we don’t plan to put it in a singleton in the firmware.

    Regards
    Lars

    #3897
    Author Image
    Martin Wagner
    Participant

    Hi Lars,
    I think that Lcd, ConsoleWriter and Led are candidates for singletons, since they provide input to unique resources on the brick (and sound, once it’s there). I’ll have a look at all of them, implement and test it for the simulation part. If you don’t mind, I’ll evaluate the effects on the hardware side as well to see whether there are chances to achieve homogenuous interfaces for the end-users.
    Best regards,
    Martin

    #3898
    Author Image
    Martin Wagner
    Participant

    Hi Lars,
    playing around with it, I realized that it is much better to keep separate instances of “Lcd”, since each instance can be a separate desktop for a thread or functional block. It’s just that you can’t mix “Lcd” and “Console”.

    To illustrate this for others, I attach some lines and pictures.

    Dim Screen1 As New Lcd
    Dim Screen2 As New Lcd
    KeyScreen = New Lcd
    => SimuClear

    Screen1.WriteText(Font.SmallFont, New Point(0, 0), “Hello from screen 1”, True)
    Screen1.Update()
    => SimuScreen1

    For i = 1 To 15
    LcdConsole.WriteLine(“Text{0} from WriteLine”, i)
    Thread.Sleep(250)
    Next
    => SimuWriteLine

    Screen2.WriteText(Font.SmallFont, New Point(0, 20), “Hello from screen 2”, True)
    Screen2.Update()
    => SimuScreen2

    No more files allowed, see next post ….

    Attachments:
    You must be logged in to view attached files.
    #3903
    Author Image
    Martin Wagner
    Participant


    Screen1.WriteText(Font.SmallFont, New Point(10, 100), “Here is screen 1 again!”, True)
    Screen1.Update()
    => SimuScreen1again
    Note: The previous text on “Desktop1” is still there.

    So I’ll leave the code as it is for the moment and keep on testing. There are still some init bugs :-(.

    See you,
    Martin

    Attachments:
    You must be logged in to view attached files.
    #3905
    Author Image
    Martin Wagner
    Participant

    Hi Lars,
    the characters don’t seem to have a background color. How to you overwrite some text? The space-character seem not to work.

    Private Sub KeyReleased() Handles ButtEvs.DownReleased, ButtEvs.EnterReleased, ButtEvs.EscapeReleased, _
    ButtEvs.LeftReleased, ButtEvs.RightReleased, ButtEvs.UpReleased
    KeyLogger(Nothing)
    End Sub

    Private Sub EnterPressed() Handles ButtEvs.EnterPressed
    KeyLogger(“Enter”)
    End Sub

    Private Sub KeyLogger(Key As String)
    Dim lp As New Point(0, 0)
    Const prefix As String = “Key pressed: ”
    If Key Is Nothing Then
    KeyScreen.WriteText(Font.SmallFont, lp, prefix & ” “, True)
    Else
    KeyScreen.WriteText(Font.SmallFont, lp, prefix & Key, True)
    End If
    KeyScreen.Update()
    End Sub
    => SimuKey
    => SimuManyKeys

    What is the best way to write different texts in the same location?

    Best regards,
    Martin

    Attachments:
    You must be logged in to view attached files.
    #3923
    Author Image
    Martin Wagner
    Participant

    Hi Anders, hi Lars,

    I dared to create a fork in the GitHub and could connect with my VisualStudio 2013 Express. Then I managed to extract code fragments from my confused SVN and could reconstruct my code. I made three commits and added both of you as contributers (necessary?). I hope you don’t mind my usage of the logo, I thought this improves corporate identity ;-). Lcd and Buttons are implemented via a HardwareAbstractionLayer, Led not yet. The HAL uses a conditional compiler symbol (Ev3Simu) in MonoBrickFirmware to separate the code regions, configurations switch between the implementations (Debug = Simu, Release = Original). As far as I know, Simu will require VisualStudio, since the GUI is based on Windows-Presentation-Foundation. Oh, Gui and TestProg are in VB.Net, since I am used to it. It still takes me so much longer to write the same ideas in C#. Maybe I’ll port it to C#, when I am more used to it. I tried to minimize the impact on the original code and come up with a HAL, that can be maintained with reasonable effort. Sensors and motors would get their HAL representations and WPF representatives in the future, too.

    What do you think of the SW concept and the result? Worthwile to go on? Do you like the result so far?

    Eagerly awaiting your feedback,
    Martin

    P.S.: Please don’t look at the TestProg, it’s just to get something on the screen.

    Attachments:
    You must be logged in to view attached files.
    #3925
    Author Image
    Anders Søborg
    Keymaster

    Hi Martin

    Once you have a created a fork – please use a pull request to get your contribution into the “official” repository… try to search youTube for a tutorial on this if you have never done it before. Don’t worry about it we will see how it goes…

    Anders

    #3928
    Author Image
    Martin Wagner
    Participant

    Hi,
    I created a branch “Simu” before sending the pull request to be sure not to interfere with the master branch. Necessary or shall work in the master branch of my fork? What is less work for you to merge?
    See you,
    Martin

    #3936
    Author Image
    Anders Søborg
    Keymaster

    Did you get the email that I send you?

    Anders

    #3959
    Author Image
    Martin Wagner
    Participant

    Hi Anders,
    yes, I got it. Did you get my reply? No hurry.
    I just can’t spend time on MonoBrick at the moment. But I’ll be back … 😉
    CU,
    Martin

Viewing 13 posts - 16 through 28 (of 28 total)

You must be logged in to reply to this topic.

Posted in

Make a donation