-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #451 from paulscottrobson/cursors
Added New Cursor graphics
- Loading branch information
Showing
16 changed files
with
167 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// *************************************************************************************** | ||
// *************************************************************************************** | ||
// | ||
// Name : cursor.h | ||
// Authors : Paul Robson ([email protected]) | ||
// Date : 13th April 2024 | ||
// Reviewed : No | ||
// Purpose : Cursor header | ||
// | ||
// *************************************************************************************** | ||
// *************************************************************************************** | ||
|
||
#ifndef _CURSOR_H | ||
#define _CURSOR_H | ||
|
||
void CURInitialise(void); | ||
const uint8_t *CURGetCurrent(uint8_t *xHit,uint8_t *yHit); | ||
bool CURSetCurrent(uint8_t cursorID); | ||
|
||
|
||
#endif | ||
|
||
// *************************************************************************************** | ||
// | ||
// Date Revision | ||
// ==== ======== | ||
// | ||
// *************************************************************************************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,32 +3,45 @@ | |
# | ||
# Name : cursors.py | ||
# Authors : Paul Robson ([email protected]) | ||
# Date : 21st March 2024 | ||
# Date : 13th April 2024 | ||
# Reviewed : No | ||
# Purpose : Converts cursors to data (monochrome only at present) | ||
# Purpose : Converts cursors to data (2nd version) | ||
# | ||
# *************************************************************************************** | ||
# *************************************************************************************** | ||
|
||
import re,os,sys | ||
from PIL import Image | ||
|
||
|
||
class Cursor(object): | ||
def __init__(self,imageFile,xClick,yClick): | ||
self.click = (xClick,yClick) | ||
self.image = Image.open("scripts"+os.sep+"cursors"+os.sep+imageFile) | ||
assert self.image.size == (16,16) | ||
self.imageData = [0xFF] * 256 | ||
self.name = imageFile[:-4].lower() | ||
for x in range(0,16): | ||
for y in range(0,16): | ||
p = self.image.getpixel((x,y)) | ||
if p[3] > 128: | ||
self.imageData[x+y*16] = 7 if p[0]+p[1]+p[2] > 512 else 0 | ||
ib = ",".join([str(x) for x in self.imageData]) | ||
print("static const uint8_t {1}_cursor_data[] = {{ {0}}};\n".format(ib,self.name)) | ||
|
||
cursors = [] | ||
print("//\n//\tThis file is automatically generated.\n//") | ||
Cursor("default.png",0,0) | ||
|
||
def convert(n): | ||
n = n & 0x0F | ||
return 0xFF if n == 0 else n | ||
|
||
src = [x for x in open("scripts/cursors/graphics.gfx","rb").read(-1)] | ||
assert src[0] == 1 and src[1] == 0 and src[3] == 0 | ||
cursorCount = src[2] | ||
|
||
print("//\n//\tThis file is automatically generated\n//\n") | ||
|
||
print("#define CURSOR_IMAGE_COUNT ({0})\n".format(cursorCount)) | ||
|
||
cursorData = [] | ||
for c in src[256:]: | ||
cursorData.append(convert(c >> 4)) | ||
cursorData.append(convert(c)) | ||
|
||
print("const uint8_t cursor_data[] = {") | ||
print(",".join([str(x) for x in cursorData])) | ||
print("};\n") | ||
|
||
hitPoint = [] | ||
for i in range(0,cursorCount): | ||
hp = [8,8] | ||
if i == 0: | ||
hp = [4,0] | ||
if i == 4 or i == 9: | ||
hp = [4,4] | ||
hitPoint += hp | ||
print("const uint8_t cursor_hitPoint[] = {") | ||
print(",".join([str(x) for x in hitPoint])) | ||
print("};\n") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# *************************************************************************************** | ||
# *************************************************************************************** | ||
# | ||
# Name : Makefile | ||
# Author : Paul Robson ([email protected]) | ||
# Date : 20th November 2023 | ||
# Reviewed : No | ||
# Purpose : Main firmware makefile, most of the work is done by CMake. | ||
# | ||
# *************************************************************************************** | ||
# *************************************************************************************** | ||
|
||
ifeq ($(OS),Windows_NT) | ||
#is this really needed? WSL2 is the 2023. | ||
include ..\..\..\..\build_env\common.make | ||
else | ||
include ../../../../build_env/common.make | ||
endif | ||
|
||
all: | ||
|
||
$(PYTHON) $(BINDIR)makeimg.zip | ||
|
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// *************************************************************************************** | ||
// *************************************************************************************** | ||
// | ||
// Name : cursor.cpp | ||
// Authors : Paul Robson ([email protected]) | ||
// Date : 13th April 2024 | ||
// Reviewed : No | ||
// Purpose : Cursor Repository. | ||
// | ||
// *************************************************************************************** | ||
// *************************************************************************************** | ||
|
||
#include "common.h" | ||
#include "data/cursors.h" | ||
static uint8_t currentCursor; | ||
|
||
// *************************************************************************************** | ||
// | ||
// Initialise cursors | ||
// | ||
// *************************************************************************************** | ||
|
||
void CURInitialise(void) { | ||
currentCursor = 0; | ||
} | ||
|
||
// *************************************************************************************** | ||
// | ||
// Get current cursor | ||
// | ||
// *************************************************************************************** | ||
|
||
const uint8_t *CURGetCurrent(uint8_t *xHit,uint8_t *yHit) { | ||
if (xHit != NULL) *xHit = cursor_hitPoint[currentCursor*2]; | ||
if (yHit != NULL) *yHit = cursor_hitPoint[currentCursor*2+1]; | ||
return cursor_data+currentCursor*256; | ||
} | ||
|
||
// *************************************************************************************** | ||
// | ||
// Set current cursor | ||
// | ||
// *************************************************************************************** | ||
|
||
bool CURSetCurrent(uint8_t cursorID) { | ||
bool isOk = cursorID < CURSOR_IMAGE_COUNT; // Number of cursors | ||
currentCursor = isOk ? cursorID : 0; // Bad value sets default | ||
return !isOk; // Return false on error | ||
} | ||
|
||
// *************************************************************************************** | ||
// | ||
// Date Revision | ||
// ==== ======== | ||
// | ||
// *************************************************************************************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters