protected ShowcaseGridLayoutBase(float scaleSize, Rectangle sourceRect, ItemGridProvider itemProvider, LayoutConfig config) { ScaleSize = scaleSize; SourceRect = sourceRect; ItemProvider = itemProvider; Config = config; }
private const uint SpiClockRate = 400; //avoid greater /// <summary> /// Create an instance of driver /// </summary> /// <param name="cspin">The output port used for the SS signal</param> public BoostHD44780( Cpu.Pin cspin, LayoutConfig config) { this.Height = config.LogicalSize >> 8; //rows this.Width = (byte)config.LogicalSize; //columns //a "physicalRow" is kinda row that can be written sequentially //to the LCD module, by taking advantage of its auto-increment //that is, a contiguous-address array of characters //each physicalRow is made of one or two "physicalBlocks" //a "physicalColumns" is the size of a physicalBlock this._physicalColumns = config.PhysicalColumns; this._physicalRow0 = config.PhysicalRow0; this._physicalRow1 = config.PhysicalRow1; //this indicates how many visible rows takes a single physicalRow int physicalBlocks = (config.PhysicalRow0 < 0x10000) ? 1 : 2; this._buffer = new byte[config.PhysicalColumns * physicalBlocks * 4 + 4]; //all phy-cells + 1 cmd //defines the first SPI slave device configuration this._spiConfig = new SPI.Configuration( cspin, // SS-pin false, // SS-pin active state 0, // The setup time for the SS port 0, // The hold time for the SS port true, // The idle state of the clock true, // The sampling clock edge (this must be "true" for the 74HC595) SpiClockRate, // The SPI clock rate in KHz (avoid faster speed) SPI_Devices.SPI1 // The used SPI bus (refers to a MOSI MISO and SCLK pinset) ); }
private void TestH() { if (!runH) { return; } layoutHContent = this.transform.Find("ScrollViewHEditor/Viewport/Content"); layoutH = layoutHContent.gameObject.AddComponent <SampleLayout>(); LayoutConfig config = new LayoutConfig(layoutHContent); config.frameWorkCnt = 0; config.bufHalfCnt = 1; layoutH.DoInit(config, GenDatas(10)); }
protected void setConfig(object sender, CommandEventArgs e) { var dao = new EsodaConfigParametersDAO(); bool success = true; msg.Attributes["style"] = "color:green;"; msg.Text = ""; if (e.CommandName == "saveLogo1") { try { if (uploadLogo1.PostedFile != null && uploadLogo1.PostedFile.ContentLength > 0) { var ext = Path.GetExtension(uploadLogo1.PostedFile.FileName); var name = "L" + Guid.NewGuid().ToString(); var targetFile = Server.MapPath("~/app_themes/standardlayout/logos/" + name + ext); foreach (var file in Directory.GetFiles(Server.MapPath("~/app_themes/standardlayout/logos"), "L*.*")) { File.Delete(file); } File.WriteAllBytes(targetFile, uploadLogo1.FileBytes); dao.SetConfigParam("logo1", name + ext); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); msg.Attributes["style"] = "color:red;"; msg.Text = "Błąd w trakcie zapisu pliku zawierającego logo"; success = false; } if (success) { msg.Text = "Konfiguracja zapisana poprawnie"; LayoutConfig.Invalidate(); return; } } if (e.CommandName == "saveLogo2") { try { if (uploadLogo2.PostedFile != null && uploadLogo2.PostedFile.ContentLength > 0) { var ext = Path.GetExtension(uploadLogo2.PostedFile.FileName); var name = "P" + Guid.NewGuid().ToString(); var targetFile = Server.MapPath("~/app_themes/standardlayout/logos/" + name + ext); foreach (var file in Directory.GetFiles(Server.MapPath("~/app_themes/standardlayout/logos"), "P*.*")) { File.Delete(file); } File.WriteAllBytes(targetFile, uploadLogo2.FileBytes); dao.SetConfigParam("logo2", name + ext); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); msg.Attributes["style"] = "color:red;"; msg.Text = "Błąd w trakcie zapisu pliku zawierającego logo"; success = false; } if (success) { msg.Text = "Konfiguracja zapisana poprawnie"; LayoutConfig.Invalidate(); } return; } if (e.CommandName == "saveBG") { var currentColor = bgColor.Text.Replace(";", "").Replace("#", ""); int res; if ((currentColor.Length == 3 || currentColor.Length == 6) && int.TryParse(currentColor, System.Globalization.NumberStyles.AllowHexSpecifier, System.Globalization.NumberFormatInfo.InvariantInfo, out res) && bgColor.Text[0] == '#') { dao.SetConfigParam("logoBG", bgColor.Text.Replace(";", "")); } else { msg.Attributes["style"] = "color:red;"; msg.Text = "Niepoprawna wartość koloru tła!"; success = false; } if (success) { msg.Text = "Kolor tła zapisany poprawnie"; LayoutConfig.Invalidate(); } return; } if (e.CommandName == "setDefault") { dao.SetConfigParam("logoBG", "#FFF4DE"); dao.SetConfigParam("logo1", "Ld.png"); dao.SetConfigParam("logo2", "Pd.png"); bgColor.Text = "#FFF4DE"; var sourceFile1 = Server.MapPath("~/app_themes/standardlayout/img/defaultlogo/logo1.png"); var targetFile1 = Server.MapPath("~/app_themes/standardlayout/logos/Ld.png"); var sourceFile2 = Server.MapPath("~/app_themes/standardlayout/img/defaultlogo/logo2.png"); var targetFile2 = Server.MapPath("~/app_themes/standardlayout/logos/Pd.png"); try { byte[] content1 = File.ReadAllBytes(sourceFile1); byte[] content2 = File.ReadAllBytes(sourceFile2); foreach (var file in Directory.GetFiles(Server.MapPath("~/app_themes/standardlayout/logos"), "*.*")) { File.Delete(file); } File.WriteAllBytes(targetFile1, content1); File.WriteAllBytes(targetFile2, content2); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); msg.Attributes["style"] = "color:red;"; msg.Text = "Błąd w trakcie przywracania wartości domyślnych"; success = false; } if (success) { msg.Text = "Konfiguracja przywrócona do wartości domyślnych"; LayoutConfig.Invalidate(); } return; } if (e.CommandName == "deleteLogo1") { try { foreach (var file in Directory.GetFiles(Server.MapPath("~/app_themes/standardlayout/logos"), "L*.*")) { File.Delete(file); } var sourceFile1 = Server.MapPath("~/app_themes/standardlayout/img/defaultlogo/empty.gif"); var targetFile1 = Server.MapPath("~/app_themes/standardlayout/logos/Ld.gif"); byte[] content1 = File.ReadAllBytes(sourceFile1); File.WriteAllBytes(targetFile1, content1); dao.SetConfigParam("logo1", "Ld.gif"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); msg.Attributes["style"] = "color:red;"; msg.Text = "Błąd w trakcie usuwania logo"; success = false; } if (success) { msg.Text = "Logo zostało usunięte"; LayoutConfig.Invalidate(); } return; } if (e.CommandName == "deleteLogo2") { try { foreach (var file in Directory.GetFiles(Server.MapPath("~/app_themes/standardlayout/logos"), "P*.*")) { File.Delete(file); } var sourceFile1 = Server.MapPath("~/app_themes/standardlayout/img/defaultlogo/empty.gif"); var targetFile1 = Server.MapPath("~/app_themes/standardlayout/logos/Pd.gif"); byte[] content1 = File.ReadAllBytes(sourceFile1); File.WriteAllBytes(targetFile1, content1); dao.SetConfigParam("logo2", "Pd.gif"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); msg.Attributes["style"] = "color:red;"; msg.Text = "Błąd w trakcie usuwania logo"; success = false; } if (success) { msg.Text = "Logo zostało usunięte"; LayoutConfig.Invalidate(); } return; } if (e.CommandName == "deleteBG") { try { dao.SetConfigParam("logoBG", "transparent"); bgColor.Text = string.Empty; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); msg.Attributes["style"] = "color:red;"; msg.Text = "Błąd w trakcie usuwania koloru tła"; success = false; } if (success) { msg.Text = "Kolor tła został usunięty"; LayoutConfig.Invalidate(); } return; } }
public ShowcaseAutoLayout(float scaleSize, Rectangle sourceRect, ItemGridProvider itemProvider, LayoutConfig config) : base(scaleSize, sourceRect, itemProvider, config) { }
public ShowcaseManualLayout(float scaleSize, LayoutConfig config) { ScaleSize = scaleSize; Config = config; }
protected LayoutConfigBuilder(LayoutConfig config) : base(config) { this.config = config; }
public async Task StartAsync( LayoutConfig config ) { if (this._timer != null) { throw new InvalidOperationException("The driver is already running."); } this.Height = config.LogicalSize >> 8; //rows this.Width = (byte)config.LogicalSize; //columns //a "physicalRow" is kinda row that can be written sequentially //to the LCD module, by taking advantage of its auto-increment //that is, a contiguous-address array of characters //each physicalRow is made of one or two "physicalBlocks" //a "physicalColumns" is the size of a physicalBlock this._physicalColumns = config.PhysicalColumns; this._physicalRow0 = config.PhysicalRow0; this._physicalRow1 = config.PhysicalRow1; //this indicates how many visible rows takes a single physicalRow int physicalBlocks = (config.PhysicalRow0 < 0x10000) ? 1 : 2; this._buffer = new byte[config.PhysicalColumns * physicalBlocks * 4 + 4]; //all phy-cells + 1 cmd this._cache = new byte[this.Height][]; for (int i = 0; i < this.Height; i++) { this._cache[i] = new byte[this.Width]; } try { var settings = new SpiConnectionSettings(SPI_CHIP_SELECT_LINE); settings.ClockFrequency = 1000 * 1000; settings.SharingMode = SpiSharingMode.Exclusive; settings.Mode = SpiMode.Mode0; string aqs = SpiDevice.GetDeviceSelector(SPI_CONTROLLER_NAME); /* Get a selector string that will return all SPI controllers on the system */ var dis = await DeviceInformation.FindAllAsync(aqs); /* Find the SPI bus controller devices with our selector string */ _spi = await SpiDevice.FromIdAsync(dis[0].Id, settings); /* Create an SpiDevice with our bus controller and SPI settings */ if (_spi == null) { //we have a problem :) return; } /** * According to the HD44780 specs (page 46), the init for * 4-bit interface should be done as follows: * - the chip could be either in the 8-bit mode, or in the 4-bit * depending on the power-on status * - send just a byte, then wait at least 4.1 ms * - send another a byte, then wait at least 100 us * doing so the chip is always under control, regardless its mode * - send one byte, and immediately the byte for the 4-bit mode * - the chip is now working in 4-bit mode **/ this._bufferIndex = 0; this.WriteCommand(LcdSetFunc8); this.Send(); await Task.Delay(5); //this yields a small pause this.WriteCommand(LcdSetFunc8); this.Send(); await Task.Delay(1); //this yields a small pause this.WriteCommand(LcdSetFunc8); this.WriteCommand(LcdSetFunc4); //at this point the HD44780 is working in 4-bit mode //complete the init WriteCommand(0x28); //set 2 rows (and 4-bit mode again) WriteCommand(0x0C); //turn on the display WriteCommand(0x06); //inc cursor, but don't shift the display WriteCommand(0x02); //return home this.Send(); this.Clear(); //start the rendering timer this._timer = new Timer(this.TimerCallback, null, 200, 200); } catch (Exception e) { //Debug.Print("Error: " + e.Message); System.Diagnostics.Debug.WriteLine(e.Message); } }
public void ResetData() { layout = null; layoutState = null; }
public void LoadData() { layout = JsonUtility.FromJson <LayoutConfig>(layoutJSON.text); industryConfig = JsonUtility.FromJson <IndustryConfig>(industryJSON.text); }