Skip to content

Instantly share code, notes, and snippets.

View southwolf's full-sized avatar

SouthWolf southwolf

  • HSBC
  • Guangzhou, China
View GitHub Profile
@southwolf
southwolf / font2pbm.rb
Created March 29, 2013 09:49
Pebble font resource to pbm(the most close format I can think of to the pebble res) converter **Faulty**
class Image
attr_accessor :width, :height, :bitmap
end
img = Image.new
hexmap = nil
File.open('font1', 'rb') do |f|
data = f.read
img.width = data[0].ord
# coding=utf-8
import Image, ImageDraw, ImageFont
import struct
font_width = 16
font = ImageFont.truetype("/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc", font_width)
def get_font_data(char):
@southwolf
southwolf / manifest.json
Last active December 15, 2015 15:09
Correct Resource Map of Pebble v1.9.1
{
"debug": {
"resourceMap": {
"friendlyVersion": "v1.8-HM",
"media": [
{
"defName": "PUG",
"file": "images/pug.png",
"type": "png"
},
# coding=utf-8
import Image, ImageDraw, ImageFont
import struct
font_width = 16
font = ImageFont.truetype("/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc", font_width)
def get_font_data(char):
@southwolf
southwolf / fontgen.py
Created April 25, 2013 22:42
Modified fontgen.py to generate basic ASCII & Russian, by changine the codepoints
#!/usr/bin/env python
# coding=utf-8
import argparse
import freetype
import os
import re
import struct
import sys
import itertools
from math import ceil
$ ./waf configure
Waf: The wscript in 'c:\\Users\\SouthWolf\\pebble\\sdk\\watches\\segment_six' is
unreadable
Traceback (most recent call last):
File "c:\Users\SouthWolf\pebble\sdk\watches\segment_six\waf-1.7.0-9334f7e963be
e5410f4fa28728feffdd\waflib\Scripting.py", line 87, in waf_entry_point
set_main_module(Context.run_dir+os.sep+Context.WSCRIPT_FILE)
File "c:\Users\SouthWolf\pebble\sdk\watches\segment_six\waf-1.7.0-9334f7e963be
e5410f4fa28728feffdd\waflib\Scripting.py", line 112, in set_main_module
Context.g_module=Context.load_module(file_path)
@southwolf
southwolf / Pebble.ino
Last active January 26, 2020 20:40
Arduino code for Communicate with Pebble
#include <string.h>
#include <ctype.h>
#include <SoftwareSerial.h>
// the Bluetooth Shield connects to Pin D9 & D10
SoftwareSerial bt(9,10);
const uint8_t req[5] = {0x00, 0x01, 0x00, 0x11, 0x00};
const uint8_t cap[17] = {0x00, 0x0d, 0x00, 0x11, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32};
const uint8_t ping[9] = {0x00, 0x05, 0x07, 0xd1, 0x00, 0xde, 0xad, 0xbe, 0xef};
#include <string.h>
#include <ctype.h>
const uint8_t req[5] = {0x00, 0x01, 0x00, 0x11, 0x00};
const uint8_t cap[17] = {0x00, 0x0d, 0x00, 0x11, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32};
const uint8_t ping[9] = {0x00, 0x05, 0x07, 0xd1, 0x00, 0xde, 0xad, 0xbe, 0xef};
const uint8_t sms[23] = {0x00, 0x13, 0x0b, 0xb8, 0x01, 0x01, 0x41, 0x01, 0x42, 0x0d, 0x31, 0x33, 0x37, 0x36, 0x34, 0x36, 0x36, 0x36, 0x35, 0x39, 0x30, 0x30, 0x30};
//uint8_t serialMessage[200];
int index = 0;
@southwolf
southwolf / sdl_yuv.cpp
Created October 11, 2013 03:20
SDL YUV display, screen freezes but code still running
int _tmain(int argc, _TCHAR* argv[])
{
FILE *in_fp;
int frameNum = 10000;
Uint32 screenWidth = 0, screenHeight = 0;
Uint32 frameSize = 0;
Uint8 *frame, *displayFrame;
SDL_RWops *handle = nullptr;
Uint32 readStart, readEnd, readTime, showStart, showEnd, showTime;
@southwolf
southwolf / gist:c8974c14d84f565caa52
Last active August 29, 2015 14:03
SDL Event Processing
while (!done)
{
if (SDL_WaitEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
view.interrupt();
decode.interrupt();
done = 1;