Home→Forums→MonoBrick EV3 Firmware→Brick-Simulator?
- This topic has 27 replies, 3 voices, and was last updated 10 years, 9 months ago by Martin Wagner.
-
AuthorPosts
-
January 17, 2014 at 21:02 #3859
Anders SøborgKeymasterHi Martin
I can’t wait to try your program
Anders
January 27, 2014 at 22:39 #3889
Martin WagnerParticipantHi 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,
MartinAttachments:
You must be logged in to view attached files.January 27, 2014 at 23:26 #3892
Martin WagnerParticipantHi Anders,
just tested my modified MonoBrickFirmware-project with Mono 2.10.9: Builds without errors or warnings, EV3 simulator runs okay.
Good night,
MartinJanuary 28, 2014 at 15:46 #3896
Lars JeppesenKeymasterHi 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
LarsJanuary 28, 2014 at 21:56 #3897
Martin WagnerParticipantHi 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,
MartinJanuary 29, 2014 at 21:29 #3898
Martin WagnerParticipantHi 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
=> SimuClearScreen1.WriteText(Font.SmallFont, New Point(0, 0), “Hello from screen 1”, True)
Screen1.Update()
=> SimuScreen1For i = 1 To 15
LcdConsole.WriteLine(“Text{0} from WriteLine”, i)
Thread.Sleep(250)
Next
=> SimuWriteLineScreen2.WriteText(Font.SmallFont, New Point(0, 20), “Hello from screen 2”, True)
Screen2.Update()
=> SimuScreen2No more files allowed, see next post ….
Attachments:
You must be logged in to view attached files.January 29, 2014 at 21:34 #3903
Martin WagnerParticipant…
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,
MartinAttachments:
You must be logged in to view attached files.January 29, 2014 at 21:41 #3905
Martin WagnerParticipantHi 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 SubPrivate Sub EnterPressed() Handles ButtEvs.EnterPressed
KeyLogger(“Enter”)
End SubPrivate 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
=> SimuManyKeysWhat is the best way to write different texts in the same location?
Best regards,
MartinAttachments:
You must be logged in to view attached files.January 31, 2014 at 23:15 #3923
Martin WagnerParticipantHi 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,
MartinP.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.February 1, 2014 at 09:19 #3925
Anders SøborgKeymasterHi 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
February 1, 2014 at 13:57 #3928
Martin WagnerParticipantHi,
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,
MartinFebruary 5, 2014 at 09:52 #3936
Anders SøborgKeymasterDid you get the email that I send you?
Anders
February 9, 2014 at 22:45 #3959
Martin WagnerParticipantHi 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 -
AuthorPosts
You must be logged in to reply to this topic.
Follow