Forum Replies Created
-
AuthorPosts
-
Martin WagnerParticipantHi Max,
could not try your template. I have to get an “un-rarer” first. Or could you provide a zipped version?
To my question:
Is it just uploading the binary or did you get a remote debugging session running with VisualStudio?
See you,
Martin
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
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,
Martin
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.
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.
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.
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.
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,
Martin
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,
Martin
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.
Martin WagnerParticipantHi Anders,
could spent some time on it again.
I finally managed to get something on the screen, inverted colors and corrupted pixels (see screenshot). It should read: “I am on the screen”I’ll get back, when there’s more to talk about.
Good night,
MartinAttachments:
You must be logged in to view attached files.
Martin WagnerParticipantIt’s just too late in the night.
I am wrong, e.g. see http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource%28v=vs.110%29.aspx, section examples. And, yes it must be a BlackWhite bitmap.
It’s just converted to colors for the export.I still don’t get the byte array converted to an image, but at least this works:
Dim p As String = “C:\Users\Martin\Documents\Visual Studio 2013\Projects\MonoBrick\Ev3Simu\TestProg”
Dim ml As New Lcd
ml.WriteText(Font.SmallFont, New Point(10, 10), “I am on the screen”, True)
LcdConsole.WriteLine(“Not visible”)
ml.Update()
ml.TakeScreenShot(p)Although LcdConsole.Writeline does not work, it seems to write to a different instance of lcd.
private class ConsoleWriter
{
Lcd lcd = new Lcd();
Font f = Font.SmallFont;
Or is it not allowed to mix lcd and LcdConsole?Good night,
Martin
Martin WagnerParticipantHi Anders,
still fighting with Lcd: I cannot convert the byte-array to an image/bitmap.
Since Width=178 and Height=128, why is the dispbuffer-size = 2944 bytes, when 178*128/8 = 2848 bytes?In all the information I found, the stride(bytes per line) is calculated
stride = width*(BitsPerPixel + 7)/8 with BitsPerPixel=1 (monochrom) I guess. Or is it a color bitmap?? (The code has color calculations.)In lcd.cs it is:
public const int Width = 178;
public const int Height = 128;
public const int bytesPrLine = (Width+7)/8; // changed to public MWBug or feature that I miss? Shouldn’t it be
public const int bytesPrLine = Width*(1+7)/8; // This doesn’t work eitherDo you have any suggestion how to convert dispBuffer in an standard Image or BitmapImage?
Any help would be great,
Martin
Martin WagnerParticipantHi Anders,
code update (buttonHAL fixed, LcdHAL created). I am struggling with the binding of Lcd to WPF.
Good night,
MartinAttachments:
You must be logged in to view attached files.
Martin WagnerParticipantHi Anders,
sorry, the singleton implementation is DotNet4 stuff and I don’t know whether it runs in Mono.
(Source: http://geekswithblogs.net/BlackRabbitCoder/archive/2010/05/19/c-system.lazylttgt-and-the-singleton-design-pattern.aspx)#region SingletonStuff
// ensures that only one instance of this class can exist, so everybody writes and reads the same variables
private ButtonHAL() { } // hiding creator// static holder for instance, need to use lambda to construct since constructor private (DotNet4 only)
private static readonly Lazy<ButtonHAL> _instance = new Lazy<ButtonHAL>(() => new ButtonHAL());// accessor for instance
public static ButtonHAL GetSingleton { get { return _instance.Value; } }
#endregion //SingletonStuffCan one of the mono experts have a look at it?
Thanks,
Martin -
AuthorPosts
Follow