Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,14 @@ nanoFramework.Console.Write("This is white on black again and on 9th line");

> Note: You can change the default font as well, you need to provide it as a property. The Cursor positions are calculated with the largest possible character.

M5Core2 and Fire have SPRAM, so you can get a full screen buffer as well. Refer to the [Graphics samples](https://github.com/nanoframework/Samples#graphics-for-screens) to understand all you can do with it.
M5Core2 and Fire have PSRAM, so you can get a full screen buffer as well. Refer to the [Graphics samples](https://github.com/nanoframework/Samples#graphics-for-screens) to understand all you can do with it.

If you have intensive graphic need with any of the M5Stack, you can adjust the memory requested. While both M5Core2 and Fire have PSRAM and can accommodate very large amount like 2 Mb or more, the ones without cannot go more than few Kb or tens of Kb.

```csharp
// This will allocate 2 Mb of memory for the graphics
M5Core2.InitializeScreen(2 * 1024 * 1024);
```

### Buttons

Expand Down
5 changes: 3 additions & 2 deletions nanoFramework.Fire/Fire.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,15 @@ public static Buzzer Buzzer
/// <summary>
/// Gets the screen.
/// </summary>
/// <param name="memoryBitMapAllocation">The memory allocation.</param>
/// <remarks>The screen initialization takes a little bit of time, if you need the screen consider using it as early as possible in your code.</remarks>
public static void InitializeScreen()
public static void InitializeScreen(int memoryBitMapAllocation = Screen.DefaultMemoryAllocationBitmap)
{
// If the screen is not needed, it's not going to be created
// Note: initialization may take a little bit of time
if (_screen == null)
{
_screen = new();
_screen = new(memoryBitMapAllocation);
Console.Font = Resource.GetFont(Resource.FontResources.consolas_regular_16);
}
}
Expand Down
14 changes: 8 additions & 6 deletions nanoFramework.Fire/Screen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ namespace nanoFramework.M5Stack
/// </summary>
public class Screen : ScreenBase
{
/// <summary>
/// Default memory allocation
/// </summary>
public const int DefaultMemoryAllocationBitmap = 320 * 240 * 4;

private const int ChipSelect = 14;
private const int DataCommand = 27;
private const int Reset = 33;
Expand All @@ -19,18 +24,15 @@ public class Screen : ScreenBase
/// <summary>
/// Initializes the screen
/// </summary>
public Screen()
/// <param name="memoryBitMapAllocation">The memory allocation.</param>
public Screen(int memoryBitMapAllocation = DefaultMemoryAllocationBitmap)
{
if (_isInitialized)
{
return;
}

#if M5CORE2 || FIRE
MemoryAllocationBitmap = 2 * 1024 * 1024;
#else
MemoryAllocationBitmap = 1024;
#endif
MemoryAllocationBitmap = memoryBitMapAllocation;
BackLightPin = 32;
Controller = new();
Controller.OpenPin(BackLightPin, PinMode.Output);
Expand Down
5 changes: 3 additions & 2 deletions nanoFramework.M5Core/M5Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,15 @@ public static Buzzer Buzzer
/// <summary>
/// Gets the screen.
/// </summary>
/// <param name="memoryBitMapAllocation">The memory allocation.</param>
/// <remarks>The screen initialization takes a little bit of time, if you need the screen consider using it as early as possible in your code.</remarks>
public static void InitializeScreen()
public static void InitializeScreen(int memoryBitMapAllocation = Screen.DefaultMemoryAllocationBitmap)
{
// If the screen is not needed, it's not going to be created
// Note: initialization may take a little bit of time
if (_screen == null)
{
_screen = new();
_screen = new(memoryBitMapAllocation);
#if M5CORE2
Console.Font = Resource.GetFont(Resource.FontResources.consolas_regular_16);
#else
Expand Down
14 changes: 8 additions & 6 deletions nanoFramework.M5Core/Screen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ namespace nanoFramework.M5Stack
/// </summary>
public class Screen : ScreenBase
{
/// <summary>
/// Default memory allocation
/// </summary>
public const int DefaultMemoryAllocationBitmap = 1024;

private const int ChipSelect = 14;
private const int DataCommand = 27;
private const int Reset = 33;
Expand All @@ -19,18 +24,15 @@ public class Screen : ScreenBase
/// <summary>
/// Initializes the screen
/// </summary>
public Screen()
/// <param name="memoryBitMapAllocation">The memory allocation.</param>
public Screen(int memoryBitMapAllocation = DefaultMemoryAllocationBitmap)
{
if (_isInitialized)
{
return;
}

#if M5CORE2 || FIRE
MemoryAllocationBitmap = 2 * 1024 * 1024;
#else
MemoryAllocationBitmap = 1024;
#endif
MemoryAllocationBitmap = memoryBitMapAllocation;
BackLightPin = 32;
Controller = new();
Controller.OpenPin(BackLightPin, PinMode.Output);
Expand Down
5 changes: 3 additions & 2 deletions nanoFramework.M5Core2/M5Core2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@ public static Ft6xx6x TouchController
/// <summary>
/// Gets the screen.
/// </summary>
/// <param name="memoryBitMapAllocation">The memory allocation.</param>
/// <remarks>The screen initialization takes a little bit of time, if you need the screen consider using it as early as possible in your code.</remarks>
public static void InitializeScreen()
public static void InitializeScreen(int memoryBitMapAllocation = Screen.DefaultMemoryAllocationBitmap)
{
// If the screen is not needed, it's not going to be created
// Note: initialization may take a little bit of time
if (_screen == null)
{
_screen = new();
_screen = new(memoryBitMapAllocation);
Console.Font = Resource.GetFont(Resource.FontResources.consolas_regular_16);
_touchController = new(I2cDevice.Create(new I2cConnectionSettings(1, Ft6xx6x.DefaultI2cAddress)));
_touchController.SetInterruptMode(false);
Expand Down
10 changes: 8 additions & 2 deletions nanoFramework.M5Core2/Screen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ namespace nanoFramework.M5Stack
/// </summary>
public class Screen : ScreenBase
{
/// <summary>
/// Default memory allocation
/// </summary>
public const int DefaultMemoryAllocationBitmap = 320 * 240 * 4;

private const int ChipSelect = 5;
private const int DataCommand = 15;
private const int Reset = -1;
Expand All @@ -25,15 +30,16 @@ public class Screen : ScreenBase
/// <summary>
/// Initializes the screen
/// </summary>
public Screen()
/// <param name="memoryBitMapAllocation">The memory allocation.</param>
public Screen(int memoryBitMapAllocation = DefaultMemoryAllocationBitmap)
{
if (_isInitialized)
{
return;
}

// We're allocating anough memory for the full screen as this is a SPRAM board
MemoryAllocationBitmap = 320 * 240 * 4;
MemoryAllocationBitmap = memoryBitMapAllocation;
BackLightPin = -1;
_power = M5Stack.M5Core2.Power;
// Enable the screen
Expand Down
5 changes: 3 additions & 2 deletions nanoFramework.M5StickCommon/M5StickCBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,15 @@ static M5StickCPlus()
/// <summary>
/// Gets the screen.
/// </summary>
/// <param name="memoryBitMapAllocation">The memory allocation.</param>
/// <remarks>The screen initialization takes a little bit of time, if you need the screen consider using it as early as possible in your code.</remarks>
public static void InitializeScreen()
public static void InitializeScreen(int memoryBitMapAllocation = Screen.DefaultMemoryAllocationBitmap)
{
// If the screen is not needed, it's not going to be created
// Note: initialization may take a little bit of time
if (_screen == null)
{
_screen = new();
_screen = new(memoryBitMapAllocation);
Console.Font = Resources.GetFont(Resources.FontResources.consolas_regular_8);
}
}
Expand Down
12 changes: 9 additions & 3 deletions nanoFramework.M5StickCommon/Screen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,30 @@ namespace nanoFramework.M5Stack
/// </summary>
public class Screen : ScreenBase
{
/// <summary>
/// Default memory allocation
/// </summary>
public const int DefaultMemoryAllocationBitmap = 1024;

private const int ChipSelect = 5;
private const int DataCommand = 23;
private const int Reset = 18;
private static Axp192 _power;
private static int _lumi;
private static bool _isInitialized = false;

/// <summary>
/// Initializes the screen
/// </summary>
public Screen()
/// <param name="memoryBitMapAllocation">The memory allocation.</param>
public Screen(int memoryBitMapAllocation = DefaultMemoryAllocationBitmap)
{
if (_isInitialized)
{
return;
}

MemoryAllocationBitmap = 1024;
MemoryAllocationBitmap = memoryBitMapAllocation;
// Not used in Stick versions, AXP is doing this
BackLightPin = -1;
#if M5STICKC
Expand Down