forked from nanoframework/Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
69 lines (59 loc) · 2.8 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using nanoFramework.Hardware.Esp32;
using nanoFramework.Presentation.Media;
using nanoFramework.UI;
using System;
using System.Diagnostics;
using System.Threading;
using System.Device.Pwm;
using System.Drawing;
namespace m5stack.screen
{
public class Program
{
public static void Main()
{
Debug.WriteLine("Hello from nanoFramework!");
// Screen init
int chipSelect;
int dataCommand;
int reset;
int backLightPin;
const bool wroover = false;
// Text to display and location on screen
const int screenWidth = 320;
const int screenHeight = 240;
const int screenBufferSize = 30 * 1024;
const int textPosX = 10;
const int textPosY = 0;
const string text = @"Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets containing
Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
if (wroover)
{
backLightPin = 5;
chipSelect = 22;
dataCommand = 21;
reset = 18;
}
else
{
backLightPin = 32;
chipSelect = 14;
dataCommand = 27;
reset = 33;
Configuration.SetPinFunction(19, DeviceFunction.SPI1_MISO);
Configuration.SetPinFunction(23, DeviceFunction.SPI1_MOSI);
Configuration.SetPinFunction(18, DeviceFunction.SPI1_CLOCK);
}
Configuration.SetPinFunction(backLightPin, DeviceFunction.PWM1);
DisplayControl.Initialize(new SpiConfiguration(1, chipSelect, dataCommand, reset, backLightPin), new ScreenConfiguration(0, 0, screenWidth, screenHeight), screenBufferSize);
Debug.WriteLine("Screen initialized");
Font DisplayFont = Resource.GetFont(Resource.FontResources.segoeuiregular12);
Bitmap charBitmap = new Bitmap(DisplayFont.MaxWidth + 1, DisplayFont.Height);
DisplayControl.Write(text, textPosX, textPosY, screenWidth, screenHeight, DisplayFont, Color.DarkBlue, Color.White);
Thread.Sleep(Timeout.Infinite);
}
}
}