Skip to content

Instantly share code, notes, and snippets.

Avatar

James H hughesjs

  • Spektrix
  • Scotland
View GitHub Profile
View io.vhdl
39 io_sync: process(clk, rst)
40 begin
41 if (rst = '1') then
42 io_pipe <= (others => '0');
43 elsif (rising_edge(clk)) then
44 io_pipe(0) <= dri; -- Add new value to start of queue
45 io_pipe <= io_pipe(io_pipe_len - 1 downto 0) & '0' ; --Left shift whole queue
46 if (io_pipe(io_pipe_len) = '1') then
47
View linq.cs
private void SaveResults()
{
List<AnswerData> answers = new List<AnswerData>();
foreach (GroupBox group in questionGroups)
{
JObject question = (JObject) group.Tag;
Enum.TryParse((string)question["questiontype"], out QuestionType qType);
AnswerData answer;
switch (qType)
{
View group.cs
private GroupBox GenerateGroupFromQuestion(JToken question)
{
GroupBox box = new GroupBox {Text = (string) question["text"], Dock = DockStyle.Fill, Tag = question};
questionGroups.Add(box);
List<Control> controls;
Enum.TryParse((string) question["questiontype"], out QuestionType qType);
switch (qType)
{
case QuestionType.MultipleChoiceExclusive:
{
View Code
private void PopulateControls()
{
JObject jsonQuestionnaire = JObject.Parse(File.ReadAllText(_metadata.FilePath));
JToken questions = jsonQuestionnaire["questions"];
List<GroupBox> groups = questions.Select(GenerateGroupFromQuestion).ToList();
TableLayoutPanel layout = new TableLayoutPanel
{
RowCount = groups.Count + 2, //Questions + header + footer
ColumnCount = 1,
Dock = DockStyle.Fill
View page.html
<!DOCTYPE html>
<meta charset='UTF-8'>
<html>
<script>
!function(e){"use strict";function t(e){if(Array.isArray(e)){for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}return Array.from(e)}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){if(t||(t="undefined"==typeof window?global:window),void 0!==t[e])return t[e];for(var i=["webkit","moz","ms","o"],r=0,o=i.length,n=e.charAt(0).toUpperCase()+e.substr(1);r<o;r++){var a=t[i[r]+n];if(void 0!==a)return a}return
@hughesjs
hughesjs / neopixel-fragment.c
Created September 12, 2019 17:40
Neopixel Send Byte
View neopixel-fragment.c
void send_byte(unsigned char byte){
/*
Send a byte to the Neopixel matrix, timings extracted from Neopixel manual
value: unsigned char -> one byte value, will be sent as bits from Neopixel pin
*/
for(unsigned char i = 0; i < 8; i++){
if(byte & 1<<i){
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET);
for (volatile unsigned char i = 0; i < 4; i++); //~700ns
@hughesjs
hughesjs / main.c
Created September 12, 2019 17:28
BT Speaker Control - Main Loop
View main.c
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_TIM10_Init();
MX_TIM11_Init();
View journalctl short-monotonic
-- Logs begin at Tue 2019-07-30 12:29:59 UTC, end at Tue 2019-07-30 12:36:07 UTC. --
[ 0.000000] archiso kernel: microcode: microcode updated early to revision 0xb4, date = 2019-04-01
[ 0.000000] archiso kernel: Linux version 5.1.15-arch1-1-ARCH (builduser@heftig-28691) (gcc version 9.1.0 (GCC)) #1 SMP PREEMPT Tue Jun 25 04:49:39 UTC 2019
[ 0.000000] archiso kernel: Command line: initrd=\EFI\archiso\intel_ucode.img initrd=\EFI\archiso\amd_ucode.img initrd=\EFI\archiso\archiso.img archisobasedir=arch archisolabel=ARCH_201907
[ 0.000000] archiso kernel: KERNEL supported cpus:
[ 0.000000] archiso kernel: Intel GenuineIntel
[ 0.000000] archiso kernel: AMD AuthenticAMD
[ 0.000000] archiso kernel: Hygon HygonGenuine
[ 0.000000] archiso kernel: Centaur CentaurHauls
[ 0.000000] archiso kernel: x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
View gist:f8bc05fbbf36a8351f4fb0dc4fb9a95e
[ 4.664767] nvme 0000:04:00.0: device [1c5c:1284] error status/mask=00000001/0000e000
[ 4.665306] nvme 0000:04:00.0: [ 0] RxErr
[ 4.665866] pcieport 0000:00:1d.0: AER: Corrected error received: 0000:04:00.0
[ 4.665959] pcieport 0000:00:1d.0: AER: Corrected error received: 0000:04:00.0
[ 4.665969] nvme 0000:04:00.0: PCIe Bus Error: severity=Corrected, type=Physical Layer, (Receiver ID)
[ 4.667038] nvme 0000:04:00.0: device [1c5c:1284] error status/mask=00000001/0000e000
[ 4.667577] nvme 0000:04:00.0: [ 0] RxErr
[ 4.668131] pcieport 0000:00:1d.0: AER: Corrected error received: 0000:04:00.0
[ 4.670114] pcieport 0000:00:1d.0: AER: Corrected error received: 0000:04:00.0
[ 4.670123] nvme 0000:04:00.0: PCIe Bus Error: severity=Corrected, type=Physical Layer, (Receiver ID)
View docker-compose.yml
version: '3'
volumes:
db:
services:
db:
image: mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: always
volumes: