Skip to content

Commit

Permalink
Update with support for the EVE4x-101G-IPS and EVE4x-40G-IPS
Browse files Browse the repository at this point in the history
  • Loading branch information
matrixraym committed Mar 5, 2021
1 parent 5a5873b commit 3129270
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 39 deletions.
52 changes: 28 additions & 24 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 36 additions & 13 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ public partial class Form1 : Form
void MakeScreen_MatrixOrbital(int DotSize)
{
EVE.Send_CMD(EVE.CMD_DLSTART); //Start a new display list
EVE.Send_CMD(EVE.VERTEXFORMAT(0)); //setup VERTEX2F to take pixel coordinates
EVE.Send_CMD(EVE.CLEAR_COLOR_RGB(0, 0, 0)); //Determine the clear screen color
EVE.Send_CMD(EVE.CLEAR(1, 1, 1)); //Clear the screen and the curren display list
EVE.Send_CMD(EVE.COLOR_RGB(26, 26, 192)); // change colour to blue
EVE.Send_CMD(EVE.POINT_SIZE(DotSize * 16)); // set point size to DotSize pixels. Points = (pixels x 16)
EVE.Send_CMD(EVE.BEGIN(EVE.POINTS)); // start drawing point
EVE.Send_CMD(EVE.TAG(1)); // Tag the blue dot with a touch ID
EVE.Send_CMD(EVE.VERTEX2II(EVE.Display_Width()/2, EVE.Display_Height()/2, 0, 0)); // place blue point
EVE.Send_CMD(EVE.VERTEX2F(EVE.Display_Width()/2, EVE.Display_Height()/2)); // place blue point
EVE.Send_CMD(EVE.END()); // end drawing point
EVE.Send_CMD(EVE.COLOR_RGB(255, 255, 255)); //Change color to white for text

Expand All @@ -40,12 +41,12 @@ void UploadToRam(UInt32 address, byte[] data)
GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned);
IntPtr pointer = pinnedArray.AddrOfPinnedObject();
int size = data.Length;
int blockSize = Math.Min(1024 * 64, data.Length);
int blockSize = Math.Min(1024 * 16, data.Length);
while (blockSize > 0)
{
EVE.StartCoProTransfer(address, 0);
EVE.HAL_SPI_WriteBuffer(pointer, (uint)blockSize);
EVE.HAL_SPI_Disable();
EVE.EVE_SPI_WriteBuffer(pointer, (uint)blockSize);
EVE.EVE_SPI_Disable();
size = size - blockSize;
address = (uint)(address + blockSize);
pointer = new IntPtr(pointer.ToInt64() + blockSize);
Expand Down Expand Up @@ -80,21 +81,30 @@ private void Form1_DragEnter(object sender, DragEventArgs e)

void DisplayImage(Image img)
{
bool halfres = false;
this.pictureBox1.Image = null;
if (!CurrentState)
return;
Bitmap source = new Bitmap(EVE.Display_Width(), EVE.Display_Height(), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
int height = EVE.Display_Height();
/* 10.1 uses too much ram for the buffer available in the EVE */
if (EVE.Display_Width() == 1280 && EVE.Display_Height() == 800)
{
height = height / 2;
halfres = true;
}
Bitmap source = new Bitmap(EVE.Display_Width(), height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
using (Graphics g = Graphics.FromImage(source))
{
float fact = ((float)EVE.Display_Width()) / source.Width;
float w = source.Width * fact;
float h = source.Height * fact;
g.Clear(Color.Black);
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
g.DrawImage(img, 0, 0,w,h);
}
pictureBox1.Image = source;
//Creat a 16 bit copy of it using the graphics class
Bitmap dest = new Bitmap(EVE.Display_Width(), EVE.Display_Height(), System.Drawing.Imaging.PixelFormat.Format16bppRgb565);
Bitmap dest = new Bitmap(EVE.Display_Width(), height, System.Drawing.Imaging.PixelFormat.Format16bppRgb565);
using (Graphics g = Graphics.FromImage(dest))
{
g.DrawImageUnscaled(source, 0, 0);
Expand All @@ -111,10 +121,17 @@ void DisplayImage(Image img)
EVE.Send_CMD(EVE.CLEAR(1, 1, 1)); //Clear the screen and the curren display list

EVE.Send_CMD(EVE.BITMAP_SOURCE(0));
EVE.Send_CMD(EVE.BITMAP_LAYOUT(EVE.RGB565, EVE.Display_Width() * 2, EVE.Display_Height()));
EVE.Send_CMD(EVE.BITMAP_LAYOUTH(EVE.Display_Width() * 2, EVE.Display_Height()));

EVE.Send_CMD(EVE.BITMAP_LAYOUT(EVE.RGB565, EVE.Display_Width() * 2, height));
EVE.Send_CMD(EVE.BITMAP_LAYOUTH(EVE.Display_Width() * 2, height));
EVE.Send_CMD(EVE.BEGIN(EVE.BITMAPS)); // Begin bitmap placement
if (halfres)
{
EVE.Send_CMD(EVE.CMD_LOADIDENTITY);
EVE.Send_CMD(EVE.CMD_SCALE);
EVE.Send_CMD(1 << 16);
EVE.Send_CMD(2 << 16);
EVE.Send_CMD(EVE.CMD_SETMATRIX);
}
EVE.Send_CMD(EVE.VERTEX2II(0, 0, 0, 0)); // Define the placement position of the previously defined holding area.
EVE.Send_CMD(EVE.END()); // end placing bitmaps

Expand Down Expand Up @@ -175,8 +192,7 @@ private void timer1_Tick(object sender, EventArgs e)
if (newState)
{
int model = cbModel.SelectedIndex+1;
// We are not using the external clock or flash, eve2 will do the trick for both 2+3
int res = EVE.FT81x_Init(model, EVE.BOARD_EVE2, EVE.TOUCH_TPN);
int res = EVE.FT81x_Init(model, model == EVE.DISPLAY_101 ? EVE.BOARD_EVE4 : EVE.BOARD_EVE2, EVE.TOUCH_TPN);
if (res != 0)
{
SetConnectButton(false);
Expand All @@ -197,6 +213,13 @@ private void timer1_Tick(object sender, EventArgs e)
SetConnectButton(true);
}
}
else if (newState == false)
{
this.pictureBox1.Image = null;
txtBridgeDetected.Text = "No";
CurrentState = false;
SetConnectButton(true);
}
}
catch
{
Expand All @@ -216,13 +239,13 @@ void SetConnectButton(bool enableConnect)
ConnectEnable = !enableConnect;
tbConnect.Text = enableConnect ? "Connect" : "Disconnect";
cbModel.Enabled = enableConnect;
CurrentState = false;
}


private void tbConnect_Click(object sender, EventArgs e)
{
ConnectEnable = !ConnectEnable;
tbConnect.Checked = ConnectEnable;
SetConnectButton(ConnectEnable);
}
}
}
3 changes: 3 additions & 0 deletions Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>122, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>74</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAIAMDAAAAAAIACoJQAAJgAAABAQAAAAABgAaAMAAM4lAAAoAAAAMAAAAGAAAAABACAAAAAAAIAl
Expand Down
17 changes: 15 additions & 2 deletions eve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ public class EVE
public const int DISPLAY_38 = 5;
public const int DISPLAY_35 = 6;
public const int DISPLAY_29 = 7;
public const int DISPLAY_40 = 8;
public const int DISPLAY_101 = 9;

public const int BOARD_EVE2 = 1;
public const int BOARD_EVE3 = 2;
public const int BOARD_EVE4 = 3;

public const int TOUCH_TPN = 0;
public const int TOUCH_TPR = 1;
Expand Down Expand Up @@ -205,6 +208,16 @@ public static UInt32 VERTEX2II(int x, int y, int handle, int cell)
return (uint)((2 << 30) | (((x) & 511) << 21) | (((y) & 511) << 12) | (((handle) & 31) << 7) | (((cell) & 127) << 0));
}

public static UInt32 VERTEX2F(int x, int y)
{
return (uint)((1 << 30) | ((x& 32767) << 15) | (y & 32767) );
}

public static UInt32 VERTEXFORMAT(int frac)
{
return (uint)((39 << 24) | frac);
}

public static UInt32 BITMAP_HANDLE(int handle) {
return (uint)((5 << 24) | (((handle) & 31) << 0));
}
Expand Down Expand Up @@ -264,7 +277,7 @@ public static int SPI_NumChannels()
public static extern void Wait4CoProFIFOEmpty();

[DllImport(EveDLL, CharSet = CharSet.Ansi)]
public static extern void HAL_SPI_Disable();
public static extern void EVE_SPI_Disable();

[DllImport(EveDLL, CharSet = CharSet.Ansi)]
public static extern void StartCoProTransfer(UInt32 address, byte reading);
Expand All @@ -273,7 +286,7 @@ public static int SPI_NumChannels()
public static extern void CoProWrCmdBuf(IntPtr buffer, UInt32 count);

[DllImport(EveDLL, CharSet = CharSet.Ansi)]
public static extern void HAL_SPI_WriteBuffer(IntPtr buffer, UInt32 count);
public static extern void EVE_SPI_WriteBuffer(IntPtr buffer, UInt32 count);



Expand Down
Binary file modified eve.dll
Binary file not shown.

0 comments on commit 3129270

Please sign in to comment.