Created
December 22, 2019 21:58
-
-
Save AlejandroRuiz/fd6501ceba88cd55374c2e150e385288 to your computer and use it in GitHub Desktop.
Meadow Demo App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class App : App<F7Micro, App> | |
{ | |
DisplayTftSpiBase display; | |
ISpiBus spiBus; | |
public App() | |
{ | |
var config = new SpiClockConfiguration(6000, SpiClockConfiguration.Mode.Mode3); | |
spiBus = Device.CreateSpiBus(Device.Pins.SCK, | |
Device.Pins.MOSI, | |
Device.Pins.MISO, | |
config); | |
display = new ST7789(device: Device, | |
spiBus: spiBus, | |
chipSelectPin: Device.Pins.D02, | |
dcPin: Device.Pins.D01, | |
resetPin: Device.Pins.D00, | |
width: 240, | |
height: 240); | |
var graphicsLib = new GraphicsLibrary(display); | |
graphicsLib.CurrentFont = new Font12x16(); | |
graphicsLib.Clear(); | |
int indent = 20; | |
graphicsLib.DrawText(indent, indent, "HOLA", Color.Yellow); | |
DelayDisplay(graphicsLib, 0); | |
graphicsLib.DrawCircle(120, 80, 30, Color.White, true); | |
DelayDisplay(graphicsLib, 100); | |
graphicsLib.DrawText(indent, 140, "CALENDARIO", Color.Yellow); | |
DelayDisplay(graphicsLib, 100); | |
graphicsLib.DrawText(indent, 160, "DE ADVIENTO", Color.Yellow); | |
DelayDisplay(graphicsLib, 100); | |
graphicsLib.DrawText(indent, 180, "C#", Color.Red); | |
DelayDisplay(graphicsLib, 100); | |
graphicsLib.DrawText(indent, 200, "2019 EN ESPANOL", Color.Orange); | |
DelayDisplay(graphicsLib, 100); | |
} | |
private void DelayDisplay(GraphicsLibrary graphicsLib, int delayInMs = 100) | |
{ | |
Thread.Sleep(delayInMs); | |
graphicsLib.Show(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static IApp app; | |
public static void Main(string[] args) | |
{ | |
// instantiate and run new meadow app | |
app = new App(); | |
Thread.Sleep(Timeout.Infinite); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment