mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Fillout settings functions
Settings menu works Movement working & TMP calibrated Tip reading sensibily Accuracy seems ok Trimmed down overshoot by biasing integral Saving to flash working, detailed idle Sleep mode Description scrolls Building for DFU working Motion detection update Use manual alg instead, using highpass filter, then sum current change vs rolling average Re-shuffle the pwm code organisation
This commit is contained in:
Binary file not shown.
22
Bootup Logo/Logo GUI/TS100 Logo Editor/TS100 Logo Editor.sln
Normal file
22
Bootup Logo/Logo GUI/TS100 Logo Editor/TS100 Logo Editor.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26430.15
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TS100 Logo Editor", "TS100 Logo Editor\TS100 Logo Editor.csproj", "{206C8AEF-3BE6-44E9-A1B0-25BF3805F1CB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{206C8AEF-3BE6-44E9-A1B0-25BF3805F1CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{206C8AEF-3BE6-44E9-A1B0-25BF3805F1CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{206C8AEF-3BE6-44E9-A1B0-25BF3805F1CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{206C8AEF-3BE6-44E9-A1B0-25BF3805F1CB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,8 @@
|
||||
<Properties StartupItem="TS100 Logo Editor/TS100 Logo Editor.csproj">
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.Workbench />
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<BreakpointStore />
|
||||
</MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
|
||||
</Properties>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
209
Bootup Logo/Logo GUI/TS100 Logo Editor/TS100 Logo Editor/Form1.Designer.cs
generated
Normal file
209
Bootup Logo/Logo GUI/TS100 Logo Editor/TS100 Logo Editor/Form1.Designer.cs
generated
Normal file
@@ -0,0 +1,209 @@
|
||||
namespace TS100_Logo_Editor
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.btnLoadImage = new System.Windows.Forms.Button();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.cbInvertImage = new System.Windows.Forms.CheckBox();
|
||||
this.gbScaling = new System.Windows.Forms.GroupBox();
|
||||
this.rbScaleStretch = new System.Windows.Forms.RadioButton();
|
||||
this.rbScaleFit = new System.Windows.Forms.RadioButton();
|
||||
this.pbImage = new System.Windows.Forms.PictureBox();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.btnSaveHex = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.gbScaling.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbImage)).BeginInit();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.btnLoadImage);
|
||||
this.groupBox1.Location = new System.Drawing.Point(20, 20);
|
||||
this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.groupBox1.Size = new System.Drawing.Size(300, 217);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "1. Load source Image";
|
||||
//
|
||||
// btnLoadImage
|
||||
//
|
||||
this.btnLoadImage.Location = new System.Drawing.Point(10, 31);
|
||||
this.btnLoadImage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.btnLoadImage.Name = "btnLoadImage";
|
||||
this.btnLoadImage.Size = new System.Drawing.Size(280, 35);
|
||||
this.btnLoadImage.TabIndex = 0;
|
||||
this.btnLoadImage.Text = "Load Image";
|
||||
this.btnLoadImage.UseVisualStyleBackColor = true;
|
||||
this.btnLoadImage.Click += new System.EventHandler(this.btnLoadImage_Click);
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.cbInvertImage);
|
||||
this.groupBox2.Controls.Add(this.gbScaling);
|
||||
this.groupBox2.Controls.Add(this.pbImage);
|
||||
this.groupBox2.Location = new System.Drawing.Point(330, 20);
|
||||
this.groupBox2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.groupBox2.Size = new System.Drawing.Size(300, 217);
|
||||
this.groupBox2.TabIndex = 1;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "2. Adjust image";
|
||||
//
|
||||
// cbInvertImage
|
||||
//
|
||||
this.cbInvertImage.AutoSize = true;
|
||||
this.cbInvertImage.Location = new System.Drawing.Point(138, 122);
|
||||
this.cbInvertImage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.cbInvertImage.Name = "cbInvertImage";
|
||||
this.cbInvertImage.Size = new System.Drawing.Size(75, 24);
|
||||
this.cbInvertImage.TabIndex = 2;
|
||||
this.cbInvertImage.Text = "Invert";
|
||||
this.cbInvertImage.UseVisualStyleBackColor = true;
|
||||
this.cbInvertImage.CheckedChanged += new System.EventHandler(this.cbInvertImage_CheckedChanged);
|
||||
//
|
||||
// gbScaling
|
||||
//
|
||||
this.gbScaling.Controls.Add(this.rbScaleStretch);
|
||||
this.gbScaling.Controls.Add(this.rbScaleFit);
|
||||
this.gbScaling.Location = new System.Drawing.Point(9, 91);
|
||||
this.gbScaling.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.gbScaling.Name = "gbScaling";
|
||||
this.gbScaling.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.gbScaling.Size = new System.Drawing.Size(120, 117);
|
||||
this.gbScaling.TabIndex = 1;
|
||||
this.gbScaling.TabStop = false;
|
||||
this.gbScaling.Text = "Scaling";
|
||||
//
|
||||
// rbScaleStretch
|
||||
//
|
||||
this.rbScaleStretch.AutoSize = true;
|
||||
this.rbScaleStretch.Location = new System.Drawing.Point(10, 68);
|
||||
this.rbScaleStretch.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.rbScaleStretch.Name = "rbScaleStretch";
|
||||
this.rbScaleStretch.Size = new System.Drawing.Size(86, 24);
|
||||
this.rbScaleStretch.TabIndex = 1;
|
||||
this.rbScaleStretch.Text = "Stretch";
|
||||
this.rbScaleStretch.UseVisualStyleBackColor = true;
|
||||
this.rbScaleStretch.CheckedChanged += new System.EventHandler(this.rbScaleStretch_CheckedChanged);
|
||||
//
|
||||
// rbScaleFit
|
||||
//
|
||||
this.rbScaleFit.AutoSize = true;
|
||||
this.rbScaleFit.Checked = true;
|
||||
this.rbScaleFit.Location = new System.Drawing.Point(10, 31);
|
||||
this.rbScaleFit.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.rbScaleFit.Name = "rbScaleFit";
|
||||
this.rbScaleFit.Size = new System.Drawing.Size(52, 24);
|
||||
this.rbScaleFit.TabIndex = 0;
|
||||
this.rbScaleFit.TabStop = true;
|
||||
this.rbScaleFit.Text = "Fit";
|
||||
this.rbScaleFit.UseVisualStyleBackColor = true;
|
||||
this.rbScaleFit.CheckedChanged += new System.EventHandler(this.rbScaleFit_CheckedChanged);
|
||||
//
|
||||
// pbImage
|
||||
//
|
||||
this.pbImage.BackColor = System.Drawing.Color.Black;
|
||||
this.pbImage.Location = new System.Drawing.Point(4, 31);
|
||||
this.pbImage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.pbImage.Name = "pbImage";
|
||||
this.pbImage.Size = new System.Drawing.Size(192, 32);
|
||||
this.pbImage.TabIndex = 0;
|
||||
this.pbImage.TabStop = false;
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
this.groupBox3.Controls.Add(this.btnSaveHex);
|
||||
this.groupBox3.Location = new System.Drawing.Point(640, 20);
|
||||
this.groupBox3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.groupBox3.Size = new System.Drawing.Size(300, 217);
|
||||
this.groupBox3.TabIndex = 2;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "3. Export";
|
||||
//
|
||||
// btnSaveHex
|
||||
//
|
||||
this.btnSaveHex.Location = new System.Drawing.Point(8, 91);
|
||||
this.btnSaveHex.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.btnSaveHex.Name = "btnSaveHex";
|
||||
this.btnSaveHex.Size = new System.Drawing.Size(280, 35);
|
||||
this.btnSaveHex.TabIndex = 0;
|
||||
this.btnSaveHex.Text = "Save DFU File";
|
||||
this.btnSaveHex.UseVisualStyleBackColor = true;
|
||||
this.btnSaveHex.Click += new System.EventHandler(this.btnSaveHex_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(963, 265);
|
||||
this.Controls.Add(this.groupBox3);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.DoubleBuffered = true;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.Name = "Form1";
|
||||
this.ShowIcon = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "TS100 Custom Logo editor";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.gbScaling.ResumeLayout(false);
|
||||
this.gbScaling.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbImage)).EndInit();
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Button btnLoadImage;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.CheckBox cbInvertImage;
|
||||
private System.Windows.Forms.GroupBox gbScaling;
|
||||
private System.Windows.Forms.RadioButton rbScaleStretch;
|
||||
private System.Windows.Forms.RadioButton rbScaleFit;
|
||||
private System.Windows.Forms.PictureBox pbImage;
|
||||
private System.Windows.Forms.GroupBox groupBox3;
|
||||
private System.Windows.Forms.Button btnSaveHex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TS100_Logo_Editor
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
Image sourceImage;
|
||||
const int LCDWidth = 96;
|
||||
Bitmap PureBMP;
|
||||
private void btnLoadImage_Click(object sender, EventArgs e)
|
||||
{
|
||||
//load in an image
|
||||
OpenFileDialog dlg = new OpenFileDialog();
|
||||
dlg.Title = "Select Image";
|
||||
dlg.Filter = "Image files (*.jpg, *.jpeg, *.bmp, *.png) | *.jpg; *.jpeg; *.bmp; *.png";
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
//user has selected an image
|
||||
string filename = dlg.FileName;
|
||||
sourceImage = Image.FromFile(filename);
|
||||
reDrawPreview();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void reDrawPreview()
|
||||
{
|
||||
PureBMP = new Bitmap(LCDWidth, 16);
|
||||
//scale mode
|
||||
if (rbScaleFit.Checked)
|
||||
{
|
||||
//fit
|
||||
float scalefactor = Math.Min((float)PureBMP.Width / (float)sourceImage.Width, (float)PureBMP.Height / (float)sourceImage.Height);
|
||||
using (Graphics g = Graphics.FromImage(PureBMP))
|
||||
{
|
||||
g.DrawImage(sourceImage, new RectangleF(0, 0, sourceImage.Width * scalefactor, sourceImage.Height * scalefactor));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//draw image stretched
|
||||
using (Graphics g = Graphics.FromImage(PureBMP))
|
||||
{
|
||||
g.DrawImage(sourceImage, new RectangleF(0, 0, LCDWidth, 16));
|
||||
}
|
||||
}
|
||||
//We now have our downsampled colour image
|
||||
//apply inversion
|
||||
if (cbInvertImage.Checked)
|
||||
{
|
||||
for (int y = 0; (y <= (PureBMP.Height - 1)); y++)
|
||||
{
|
||||
for (int x = 0; (x <= (PureBMP.Width - 1)); x++)
|
||||
{
|
||||
Color inv = PureBMP.GetPixel(x, y);
|
||||
inv = Color.FromArgb(255, (255 - inv.R), (255 - inv.G), (255 - inv.B));
|
||||
PureBMP.SetPixel(x, y, inv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Threshold image
|
||||
PureBMP = GrayScale(PureBMP);
|
||||
//draw image at 2x scale
|
||||
Bitmap bBig = new Bitmap(pbImage.Width, pbImage.Height);
|
||||
using (Graphics g = Graphics.FromImage(bBig))
|
||||
{
|
||||
g.DrawImage(PureBMP, new RectangleF(0, 0, pbImage.Width, pbImage.Height));
|
||||
}
|
||||
pbImage.Image = bBig;
|
||||
}
|
||||
public Bitmap GrayScale(Bitmap Bmp)
|
||||
{
|
||||
int rgb;
|
||||
Color c;
|
||||
|
||||
for (int y = 0; y < Bmp.Height; y++)
|
||||
for (int x = 0; x < Bmp.Width; x++)
|
||||
{
|
||||
c = Bmp.GetPixel(x, y);
|
||||
rgb = (int)((c.R + c.G + c.B) / 3);
|
||||
if (rgb > 128)
|
||||
rgb = 0xFF;
|
||||
else
|
||||
rgb = 0x00;
|
||||
Bmp.SetPixel(x, y, Color.FromArgb(rgb, rgb, rgb));
|
||||
}
|
||||
return Bmp;
|
||||
}
|
||||
|
||||
private void rbScaleStretch_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
reDrawPreview();
|
||||
}
|
||||
|
||||
private void rbScaleFit_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
reDrawPreview();
|
||||
}
|
||||
|
||||
private void cbInvertImage_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
reDrawPreview();
|
||||
}
|
||||
|
||||
private void btnSaveHex_Click(object sender, EventArgs e)
|
||||
{
|
||||
Bitmap bmp = PureBMP;
|
||||
//convert image to byte array
|
||||
byte[] data = new byte[1024];
|
||||
data[0] = 0xAA;
|
||||
data[1] = 0x55;
|
||||
data[2] = 0xF0;
|
||||
data[3] = 0x0D;
|
||||
|
||||
for (int i = 0; i < (LCDWidth * 16 / 8); i++)
|
||||
{
|
||||
//loop through all the bytes
|
||||
byte b = 0;//local byte
|
||||
//i sets the starting column
|
||||
for (int y = 0; y < 8; y++)
|
||||
{
|
||||
var px = bmp.GetPixel(i % LCDWidth, (i / LCDWidth) == 1 ? 8 + y : y);
|
||||
//we loop down the picture
|
||||
//LSB is the top, MSB is the bottom
|
||||
if (px.R >= 128)
|
||||
{
|
||||
//pixel is white
|
||||
b |= (byte)(1 << y);
|
||||
}
|
||||
}
|
||||
data[i + 4] = b;
|
||||
}
|
||||
//We should now have the byte array that represents the image in the LCD format.
|
||||
//We now send this off to be encoded by the Intel Encoder
|
||||
//Flip all uint16_t pairs
|
||||
for (int i = 0; i < data.Length; i += 2)
|
||||
{
|
||||
//we need to swap each pair
|
||||
byte temp = data[i];
|
||||
data[i] = data[i + 1];
|
||||
data[i + 1] = temp;
|
||||
}
|
||||
string outputHexFile = IntelHex.IntelHex.encode(data, 0x0800B800, 16, true, true);//16 bytes is the only format the DFU seems to support //0x0800B800
|
||||
//^ This string now just needs to be written out to a text file :)
|
||||
SaveFileDialog dlg = new SaveFileDialog();
|
||||
dlg.Title = "Save DFU File";
|
||||
dlg.AddExtension = true;
|
||||
dlg.DefaultExt = ".hex";
|
||||
dlg.Filter = "Hex Files(*.hex)|*.hex";
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
//The user has selected where they want to save the file
|
||||
using (var fs = new System.IO.StreamWriter(dlg.FileName))
|
||||
{
|
||||
fs.Write(outputHexFile);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
|
||||
namespace IntelHex
|
||||
{
|
||||
public class IntelHex
|
||||
{
|
||||
public static string encode(byte[] data, UInt32 startingAddress, int bytesPerLine, bool header = true,bool Addbloat=false)
|
||||
{
|
||||
//We are taking the byte array and encoding it into the wanted hex file contents (aka string of data).
|
||||
//First create the starting base address record
|
||||
//:020000040800F2
|
||||
string Output = "";
|
||||
if (header)
|
||||
{
|
||||
//Set the upper 16 bits of the address space
|
||||
Output += getHighAddressSetLine((UInt16)(startingAddress >> 16));
|
||||
}
|
||||
|
||||
//Now loop through all the data that we were given
|
||||
for (UInt32 index = 0; index < data.Length; index = (UInt32)(index + bytesPerLine))
|
||||
{
|
||||
//We want to read from data[index] to data[index+bytesPerLine-1]
|
||||
UInt32 currentAddress = (UInt32)(startingAddress + index);
|
||||
if ((currentAddress >> 16) != (startingAddress >> 16))
|
||||
{
|
||||
Output += getHighAddressSetLine((UInt16)(currentAddress >> 16));
|
||||
//The address has rolled over the 64K boundry, so write a new high address change line
|
||||
}
|
||||
//We should now be good for the higher part of the address
|
||||
Output += encodeDataLine((UInt16)(currentAddress & 0xFFFF), data, index, bytesPerLine);
|
||||
}
|
||||
if(Addbloat)
|
||||
{
|
||||
//Repeat the instructs a stack of times to get around filesize minimums
|
||||
for(int x=0;x<3;x++)
|
||||
{
|
||||
for (UInt32 index = 0; index < data.Length; index = (UInt32)(index + bytesPerLine))
|
||||
{
|
||||
//We want to read from data[index] to data[index+bytesPerLine-1]
|
||||
UInt32 currentAddress = (UInt32)(startingAddress + index);
|
||||
if ((currentAddress >> 16) != (startingAddress >> 16))
|
||||
{
|
||||
Output += getHighAddressSetLine((UInt16)(currentAddress >> 16));
|
||||
//The address has rolled over the 64K boundry, so write a new high address change line
|
||||
}
|
||||
//We should now be good for the higher part of the address
|
||||
Output += encodeDataLine((UInt16)(currentAddress & 0xFFFF), data, index, bytesPerLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
//We have now written out all the data lines
|
||||
Output += ":00000001FF\r\n";//End of file marker
|
||||
|
||||
return Output;
|
||||
}
|
||||
private static string encodeDataLine(UInt16 address, byte[] data, UInt32 startindex, int bytes)
|
||||
{
|
||||
string line = ":";
|
||||
line += bytes.ToString("X2");//add the marker of line length
|
||||
line += address.ToString("X4");//write the address
|
||||
line += "00";//Data line
|
||||
//Next copy bytes bytes
|
||||
for (int i = 0; i < bytes; i++)
|
||||
{
|
||||
if ((startindex + i) < data.Length)
|
||||
line += data[startindex + i].ToString("X2");
|
||||
else
|
||||
line += "FF";//pad images out with FF
|
||||
}
|
||||
line += checksumLine(line);//Adds checksum and EOL
|
||||
return line;
|
||||
}
|
||||
private static string getHighAddressSetLine(UInt16 HighAddress)
|
||||
{
|
||||
string Output = "";
|
||||
Output += ":02000004" + (HighAddress).ToString("X4");
|
||||
Output += checksumLine(Output);
|
||||
return Output;
|
||||
}
|
||||
private static string checksumLine(string line)
|
||||
{
|
||||
//We want to convert the string line to each byte and sum.
|
||||
byte sum = 0;
|
||||
for (int i = 1; i < line.Length; i += 2)
|
||||
{
|
||||
byte b = byte.Parse((line.Substring(i, 2)), System.Globalization.NumberStyles.HexNumber);
|
||||
sum += b;
|
||||
}
|
||||
byte checksum = (byte)(((byte)0) - sum);//invert
|
||||
return checksum.ToString("X2") + "\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TS100_Logo_Editor
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TS100 Logo Editor")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TS100 Logo Editor")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("206c8aef-3be6-44e9-a1b0-25bf3805f1cb")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
63
Bootup Logo/Logo GUI/TS100 Logo Editor/TS100 Logo Editor/Properties/Resources.Designer.cs
generated
Normal file
63
Bootup Logo/Logo GUI/TS100 Logo Editor/TS100 Logo Editor/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace TS100_Logo_Editor.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TS100_Logo_Editor.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
26
Bootup Logo/Logo GUI/TS100 Logo Editor/TS100 Logo Editor/Properties/Settings.Designer.cs
generated
Normal file
26
Bootup Logo/Logo GUI/TS100 Logo Editor/TS100 Logo Editor/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace TS100_Logo_Editor.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{206C8AEF-3BE6-44E9-A1B0-25BF3805F1CB}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>TS100_Logo_Editor</RootNamespace>
|
||||
<AssemblyName>TS100 Logo Editor</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>
|
||||
</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>TS100_Logo_Editor.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="IntelHex.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1 @@
|
||||
1f6b9b8bf2c9e759acd19ce919cfeae19b243aa0
|
||||
251
Bootup Logo/python_logo_converter/img2ts100.py
Normal file
251
Bootup Logo/python_logo_converter/img2ts100.py
Normal file
@@ -0,0 +1,251 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
VERSION_STRING = '0.01'
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
import PIL, PIL.Image, PIL.ImageOps
|
||||
except ImportError,error:
|
||||
raise ImportError, "%s: %s requres Python Imaging Library (PIL). " \
|
||||
"Install with `pip` or OS-specific package " \
|
||||
"management tool." \
|
||||
% (error, sys.argv[0])
|
||||
|
||||
|
||||
|
||||
LCD_WIDTH = 96
|
||||
LCD_HEIGHT = 16
|
||||
LCD_NUM_BYTES = LCD_WIDTH * LCD_HEIGHT / 8
|
||||
LCD_PADDED_SIZE = 1024
|
||||
|
||||
INTELHEX_DATA_RECORD = 0x00
|
||||
INTELHEX_END_OF_FILE_RECORD = 0x01
|
||||
INTELHEX_EXTENDED_LINEAR_ADDRESS_RECORD = 0x04
|
||||
INTELHEX_BYTES_PER_LINE = 16
|
||||
INTELHEX_MINIMUM_SIZE = 4096
|
||||
|
||||
|
||||
|
||||
def split16(word):
|
||||
'''return high and low byte of 16-bit word value as tuple'''
|
||||
return ((word >> 8) & 0xff, word & 0xff)
|
||||
|
||||
|
||||
|
||||
def intel_hex_line(file, record_type, offset, data):
|
||||
'''write a line of data in Intel hex format'''
|
||||
# length, address offset, record type
|
||||
record_length = len(data)
|
||||
file.write(':%02X%04X%02X' % (record_length, offset, record_type))
|
||||
|
||||
# data
|
||||
map(lambda byte: file.write("%02X" % byte), data)
|
||||
|
||||
# compute and write checksum (with DOS line ending for compatibility/safety)
|
||||
file.write( "%02X\r\n"
|
||||
% ( ( ( sum(data, # sum data ...
|
||||
record_length # ... and other ...
|
||||
+ sum(split16(offset)) # ... fields ...
|
||||
+ record_type) # ... on line
|
||||
& 0xff) # low 8 bits
|
||||
^ 0xff) # two's ...
|
||||
+ 1)) # ... complement
|
||||
|
||||
|
||||
|
||||
def intel_hex(file, bytes, start_address = 0x0):
|
||||
'''write block of data in Intel hex format'''
|
||||
if len(bytes) % INTELHEX_BYTES_PER_LINE != 0:
|
||||
raise ValueError, \
|
||||
"Program error: Size of LCD data is not evenly divisible by %s" \
|
||||
% INTELHEX_BYTES_PER_LINE
|
||||
|
||||
address_lo = start_address & 0xffff
|
||||
address_hi = (start_address >> 16) & 0xffff
|
||||
|
||||
intel_hex_line(file,
|
||||
INTELHEX_EXTENDED_LINEAR_ADDRESS_RECORD,
|
||||
0,
|
||||
split16(address_hi))
|
||||
|
||||
size_written = 0
|
||||
while size_written < INTELHEX_MINIMUM_SIZE:
|
||||
offset = address_lo
|
||||
for line_start in range(0, len(bytes), INTELHEX_BYTES_PER_LINE):
|
||||
intel_hex_line(file,
|
||||
INTELHEX_DATA_RECORD,
|
||||
offset,
|
||||
bytes[line_start:line_start+INTELHEX_BYTES_PER_LINE])
|
||||
size_written += INTELHEX_BYTES_PER_LINE
|
||||
if size_written >= INTELHEX_MINIMUM_SIZE:
|
||||
break
|
||||
offset += INTELHEX_BYTES_PER_LINE
|
||||
|
||||
intel_hex_line(file, INTELHEX_END_OF_FILE_RECORD, 0, ())
|
||||
|
||||
|
||||
|
||||
def img2hex(input_filename,
|
||||
output_file,
|
||||
preview_filename=None,
|
||||
threshold=128,
|
||||
dither=False,
|
||||
negative=False):
|
||||
'''
|
||||
Convert 'input_filename' image file into Intel hex format with data
|
||||
formatted for display on TS100 LCD and file object.
|
||||
Input image is converted from color or grayscale to black-and-white,
|
||||
and resized to fit TS100 LCD screen as necessary.
|
||||
Optionally write resized/thresholded/black-and-white preview image
|
||||
to file specified by name.
|
||||
Optional `threshold' argument 8 bit value; grayscale pixels greater than
|
||||
this become 1 (white) in output, less than become 0 (black).
|
||||
Unless optional `dither', in which case PIL grayscale-to-black/white
|
||||
dithering algorithm used.
|
||||
Optional `negative' inverts black/white regardless of input image type
|
||||
or other options.
|
||||
'''
|
||||
|
||||
try:
|
||||
image = PIL.Image.open(input_filename)
|
||||
except BaseException,error:
|
||||
raise IOError, \
|
||||
"error reading image file \"%s\": %s" % (input_filename, error)
|
||||
|
||||
# convert to luminance
|
||||
# do even if already black/white because PIL can't invert 1-bit so
|
||||
# can't just pass thru in case --negative flag
|
||||
# also resizing works better in luminance than black/white
|
||||
# also no information loss converting black/white to grayscale
|
||||
if image.mode != 'L':
|
||||
image = image.convert('L')
|
||||
|
||||
if image.size != (LCD_WIDTH, LCD_HEIGHT):
|
||||
image = image.resize((LCD_WIDTH, LCD_HEIGHT), PIL.Image.BICUBIC)
|
||||
|
||||
if negative:
|
||||
image = PIL.ImageOps.invert(image)
|
||||
threshold = 255 - threshold # have to invert threshold
|
||||
|
||||
if dither:
|
||||
image = image.convert('1')
|
||||
else:
|
||||
image = image.point(lambda pixel: 0 if pixel < threshold else 1, '1')
|
||||
|
||||
if preview_filename: image.save(preview_filename)
|
||||
|
||||
''' DEBUG
|
||||
for row in range(LCD_HEIGHT):
|
||||
for column in range(LCD_WIDTH):
|
||||
if image.getpixel((column, row)): sys.stderr.write('1')
|
||||
else: sys.stderr.write('0')
|
||||
sys.stderr.write('\n')
|
||||
'''
|
||||
|
||||
# pad to this size (also will be repeated in output Intel hex file)
|
||||
data = [0] * LCD_PADDED_SIZE
|
||||
|
||||
# magic/undocumented/required header in endian-reverse byte order
|
||||
data[0] = 0x55
|
||||
data[1] = 0xAA
|
||||
data[2] = 0x0D
|
||||
data[3] = 0xF0
|
||||
|
||||
# convert to TS100 LCD format
|
||||
for ndx in range(LCD_WIDTH * 16 / 8):
|
||||
bottom_half_offset = 0 if ndx < LCD_WIDTH else 8
|
||||
byte = 0
|
||||
for y in range(8):
|
||||
if image.getpixel((ndx % LCD_WIDTH, y + bottom_half_offset)):
|
||||
byte |= 1 << y
|
||||
# store in endian-reversed byte order
|
||||
data[4 + ndx + (1 if ndx % 2 == 0 else -1)] = byte
|
||||
|
||||
intel_hex(output_file, data, 0x0800B800)
|
||||
|
||||
|
||||
|
||||
def parse_commandline():
|
||||
parser = argparse.ArgumentParser(
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
||||
description="Convert image file for display on TS100 LCD "
|
||||
"at startup")
|
||||
|
||||
def zero_to_255(text):
|
||||
try:
|
||||
value = int(text)
|
||||
assert(value >= 0 and value <= 255)
|
||||
except:
|
||||
raise argparse.ArgumentTypeError("must be integer from 0 to 255 ")
|
||||
return value
|
||||
|
||||
parser.add_argument('input_filename',
|
||||
help="input image file")
|
||||
|
||||
parser.add_argument('output_filename',
|
||||
help="output Intel hex file")
|
||||
|
||||
parser.add_argument('-p', '--preview',
|
||||
help="filename of image preview (same data as "
|
||||
"Intel hex file, as will appear on TS100 LCD)")
|
||||
|
||||
parser.add_argument('-n', '--negative',
|
||||
action='store_true',
|
||||
help="photo negative: exchange black and white "
|
||||
"in output")
|
||||
|
||||
parser.add_argument('-t', '--threshold',
|
||||
type=zero_to_255,
|
||||
default=128,
|
||||
help="0 to 255: gray (or color converted to gray) "
|
||||
"above this becomes white, below becomes black; "
|
||||
"ignored if using --dither")
|
||||
|
||||
parser.add_argument('-d', '--dither',
|
||||
action='store_true',
|
||||
help="use dithering (speckling) to convert gray or "
|
||||
"color to black and white")
|
||||
|
||||
parser.add_argument('-f', '--force',
|
||||
action='store_true',
|
||||
help="force overwriting of existing files")
|
||||
|
||||
parser.add_argument('-v', '--version',
|
||||
action='version',
|
||||
version="%(prog)s version " + VERSION_STRING,
|
||||
help="print version info")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
args = parse_commandline()
|
||||
|
||||
if os.path.exists(args.output_filename) and not args.force:
|
||||
sys.stderr.write( "Won't overwrite existing file \"%s\" (use --force "
|
||||
"option to override)\n"
|
||||
% args.output_filename)
|
||||
sys.exit(1)
|
||||
|
||||
if args.preview and os.path.exists(args.preview) and not args.force:
|
||||
sys.stderr.write( "Won't overwrite existing file \"%s\" (use --force "
|
||||
"option to override)\n"
|
||||
% args.preview)
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
with open(args.output_filename, 'w') as output_file:
|
||||
img2hex(args.input_filename,
|
||||
output_file,
|
||||
args.preview,
|
||||
args.threshold,
|
||||
args.dither,
|
||||
args.negative)
|
||||
except BaseException,error:
|
||||
sys.stderr.write("Error converting file: %s\n" % error)
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user