Skip to content

Instantly share code, notes, and snippets.

View yashi's full-sized avatar

Yasushi SHOJI yashi

View GitHub Profile
@yashi
yashi / CMakeLists.txt
Created January 5, 2023 13:34
Interface library with a generated header file
cmake_minimum_required(VERSION 3.25)
project(test)
add_executable(hello hello.c)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/foo.h
# Ninja always implicitly creates target directories
COMMAND mkdir -p include/
COMMAND touch include/foo.h)
@yashi
yashi / pixelsize.c
Last active February 20, 2022 23:13
List pixel widths from front size 10 to 30 for given fonts
#include <libgen.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#define DPI (96) /* device resolution */
void die(void)
{
printf("oops\n");
exit(1);
digraph G {
edge [weight=10]
TAI -> UTC [label="−∆AT"];
UTC -> UT1 [label="+∆UT1"]
UT1 -> TT [label="+∆T"]
TT -> TCG [label="linear"]
TCG -> TCB [label="4 D"]
TCB -> TDB [label="Linear"]
edge [weight=2]
@yashi
yashi / print_radius.c
Created January 15, 2022 07:13
Print radius with NASA NAIF SPICE
#include <stdio.h>
#include "SpiceUsr.h"
int main()
{
SpiceBoolean found;
SpiceInt nr;
SpiceDouble radii[3];
SpiceInt code;
SpiceChar name[] = "Io";
@yashi
yashi / gist:69f44b16fd00825a717724174b6e1a64
Created December 20, 2021 12:33
Emulate hashFiles() with sha256sum
To emulate `hashFiles()` in GitHub Actions with `sha256sum`, you can do
```shell
sha256sum file | cut -f1 -d ' ' | xxd -r -p | sha256sum
```
@yashi
yashi / rinngbuf.c
Last active November 4, 2021 18:10
#include <zephyr.h>
#include <sys/printk.h>
#include <sys/ring_buffer.h>
#define RING_BUF_SIZE 10
RING_BUF_ITEM_DECLARE_SIZE(ringbuf, RING_BUF_SIZE);
void dump(struct ring_buf *r, uint32_t ret)
{
printk("ret %3u, size %3u space %3u head %3u tail %3u\n",
#include <drivers/led.h>
void main(void)
{
const struct device *led = device_get_binding("SC LED");
while (1) {
led_on(led, 1);
k_msleep(1000);
led_off(led, 1);
@yashi
yashi / main.c
Created July 30, 2019 13:06
k_sched_unlock debug code
#include <zephyr.h>
#define MY_STACK_SIZE 5000
K_THREAD_STACK_DEFINE(preempt_stack, MY_STACK_SIZE);
struct k_thread preempt_thread;
K_THREAD_STACK_DEFINE(coop_stack, MY_STACK_SIZE);
struct k_thread coop_thread;
@yashi
yashi / cgt.diff
Last active October 3, 2018 11:07
testing cgt
commit f6d27ac92
Author: Yasushi SHOJI <y-shoji@ispace-inc.com>
Date: Wed Sep 26 00:06:46 2018 +0900
add cgt support
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 42cbfc88f..2f72fc7eb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@yashi
yashi / compiler-driver-cgt.py
Created September 24, 2018 12:50
compiler driver for zephyr
#!/usr/bin/env python3
import os
import sys
import re
import subprocess
import argparse
import unittest
compiler_options = [