Buenas
After 2 days in Paris where I could write little and learn a lot; Today we are going with a pure and simple code example
How to paint a chart in a display pixel to pixel with. Net Gadgeteer .
In this example we will use the following
- Fez Spider Mainboard
http://savecomm.net/p/53/fez-spider-starter-kit - USB Client DP
http://www.netmf.com/showcase.aspx?ShowcaseID=1 & id = 110 - Display_T35
http://www.ghielectronics.com/catalog/product/276 - Button Module
http://www.ghielectronics.com/catalog/product/274
Organized with the following schema:
I must emphasise the application code
- line 19, at the press of the Button in addition to stop and start the timer, turn on and turn off the LED of the button
- line 32, the routine that draws the chart is the most simple, increases a counter between 20 and 40 and then it decreases. There is also a second flag to control the vertical advance
1: using GT = Gadgeteer;
2:
3: namespace GadgeteerApp6
4: {
5: public partial class Program
6: {
7: private uint _axisX = 20;
8: private uint _axisY = 20;
9: private GT.Timer _timer;
10: private bool _modeUp = true;
11:
12: void ProgramStarted()
13: {
14: button.ButtonPressed += ButtonButtonPressed;
15: _timer = new GT.Timer(200);
16: _timer.Tick += TimerTick;
17: }
18:
19: void ButtonButtonPressed(GT.Modules.GHIElectronics.Button sender, GT.Modules.GHIElectronics.Button.ButtonState state)
20: {
21: button.ToggleLED();
22: if (_timer.IsRunning)
23: {
24: _timer.Stop();
25: }
26: else
27: {
28: _timer.Start();
29: }
30: }
31:
32: void TimerTick(GT.Timer timer)
33: {
34: _axisY++;
35: if (_axisY + 10 > display_T35.SimpleGraphics.Height)
36: {
37: display_T35.SimpleGraphics.Clear();
38: _axisY = 20;
39: }
40: if (_modeUp && _axisX > 40)
41: {
42: _modeUp = false;
43: }
44: if (!_modeUp && _axisX < 20)
45: {
46: _modeUp = true;
47: }
48: if (_modeUp)
49: {
50: _axisX++;
51: }
52: else
53: {
54: _axisX--;
55: }
56: display_T35.SimpleGraphics.SetPixel(GT.Color.Green, _axisX, _axisY);
57: for (uint i = 1; i < 15; i++)
58: {
59: display_T35.SimpleGraphics.SetPixel(GT.Color.Red, _axisX + i, _axisY);
60: }
61: }
62: }
63: }
And already tomorrow to Santa Pola to show these things live with friends of GuseNet .
Saludos @ Santa Pola
El Bruno
Leave a comment