forked fromflipperdevices/flipperzero-firmware
Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork589
Poker updates, script updates#55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
102 commits Select commitHold shift + click to select a range
ed6b23b Improve directions on how to find dimensions, which are kinda importa…
PixlEmly9b6a6a2 Merge branch 'unleashed' of https://github.com/PixlEmly/flipperzero-f…
PixlEmlyf0310aa encode will print out image dimensions
PixlEmly3e3e917 Merge branch 'RogueMaster:unleashed' into unleashed
PixlEmly11f4166 Update ReadMe.md
PixlEmlyd2b01dd QOL
PixlEmlya46663f Merge branch 'unleashed' of https://github.com/PixlEmly/flipperzero-f…
PixlEmly5456f5c New: decoder for heatshrunk char array icons.
PixlEmlya172bef help info
PixlEmly831b5b0 re-arrange params
PixlEmlya09acc5 QOL
PixlEmly6bdf24d Update ReadMe.md
PixlEmlyd3eb86d icon encoder added
PixlEmly4cc1520 Merge branch 'unleashed' of https://github.com/PixlEmly/flipperzero-f…
PixlEmlyb7af240 s
PixlEmly40cc775 cleanup
PixlEmlycb27c8c Update ReadMe.md
PixlEmlyea0bca1 Update ReadMe.md
PixlEmlycc71790 Update ReadMe.md
PixlEmly78f8f27 I can't count
PixlEmly5adddb8 box tutorial
PixlEmly0c6fcbb Box Mover but added stuff
PixlEmly63f9b7e Improved bounds checks
PixlEmly3a6430d Video Poker game
PixlEmly4e51aef Merge branch 'RogueMaster:unleashed' into unleashed
PixlEmlyc6b91e9 Box Mover Splash Screen!
PixlEmlycfad248 Merge branch 'unleashed' of https://github.com/PixlEmly/flipperzero-f…
PixlEmly50b591d Update README.md
PixlEmlye9ae930 Update README.md
PixlEmly7592fa5 Merge branch 'RogueMaster:unleashed' into unleashed
PixlEmly815d687 Update README.md
PixlEmly69bf5d0 INITIAL Video Poker - it works! It's messy!
PixlEmlye82d5cb Still a bit messy. But it seems to be good now.
PixlEmly1e9c301 Still a bit messy. But it seems to be good now.
PixlEmlyd58b183 Merge branch 'unleashed' of https://github.com/PixlEmly/flipperzero-f…
PixlEmlyfe3b4b3 Improve directions on how to find dimensions, which are kinda importa…
PixlEmly61d0bbf encode will print out image dimensions
PixlEmly59f5a0d QOL
PixlEmly907596b Update ReadMe.md
PixlEmly4bb7f13 New: decoder for heatshrunk char array icons.
PixlEmlya987a28 help info
PixlEmlyd1e6c3f re-arrange params
PixlEmly54946d0 QOL
PixlEmly14fd8b8 icon encoder added
PixlEmlyca21fcb cleanup
PixlEmly5cb5068 I can't count
PixlEmly9158eb6 box tutorial
PixlEmlycdeaf0e Box Mover but added stuff
PixlEmlyc852a51 Improved bounds checks
PixlEmly3f4484b Video Poker game
PixlEmly8876a68 Box Mover Splash Screen!
PixlEmly42ac2fe INITIAL Video Poker - it works! It's messy!
PixlEmly8d439c4 Still a bit messy. But it seems to be good now.
PixlEmly19e5dc2 Update README.md
PixlEmlyfd47251 Update README.md
PixlEmlyc2ca751 Update README.md
PixlEmlyd692a93 Merge branch 'unleashed' of https://github.com/PixlEmly/flipperzero-f…
PixlEmly6978355 Attribution ;)
PixlEmlydb25fe0 Improve directions on how to find dimensions, which are kinda importa…
PixlEmly5bb8432 encode will print out image dimensions
PixlEmly1caa422 QOL
PixlEmly5992e09 Update ReadMe.md
PixlEmlye6c6108 New: decoder for heatshrunk char array icons.
PixlEmly5dedb8a help info
PixlEmlyf59a4a1 re-arrange params
PixlEmly6e507af QOL
PixlEmly281bde1 icon encoder added
PixlEmly20abbca cleanup
PixlEmly5b19fe3 I can't count
PixlEmly31ceca3 box tutorial
PixlEmly52f29df Box Mover but added stuff
PixlEmly10cef4b Improved bounds checks
PixlEmlye0378e8 Video Poker game
PixlEmlyd94e64c INITIAL Video Poker - it works! It's messy!
PixlEmly1a80d50 Still a bit messy. But it seems to be good now.
PixlEmly188f626 Update README.md
PixlEmlyb389bb2 Improve directions on how to find dimensions, which are kinda importa…
PixlEmly7488ea8 encode will print out image dimensions
PixlEmly700cf51 QOL
PixlEmly05e7669 Update ReadMe.md
PixlEmly9231898 New: decoder for heatshrunk char array icons.
PixlEmly71efb77 help info
PixlEmly669eb2d re-arrange params
PixlEmly9e47966 QOL
PixlEmly3522512 Update ReadMe.md
PixlEmly42aee38 s
PixlEmlyb193390 Update ReadMe.md
PixlEmly9c139cf Update ReadMe.md
PixlEmly1365c21 Update ReadMe.md
PixlEmly975c8ab I can't count
PixlEmly78dd160 box tutorial
PixlEmly42cd856 Box Mover but added stuff
PixlEmlyde014f3 Improved bounds checks
PixlEmly87d2a69 Attribution ;)
PixlEmlybdc5574 wtf
PixlEmlyff975d4 fuk
PixlEmlyd1580e0 nuke and cleanup
PixlEmly84739fd nuke and cleanup II
PixlEmly8aa2f0d nuke and cleanup III
PixlEmlya506b19 nuke and cleanup IV
PixlEmly3380410 Poker cleaned up, less globals, better alignment, some comments
PixlEmly9867e00 Update to scripts
PixlEmlyFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
249 changes: 107 additions & 142 deletionsapplications/VideoPoker/poker.c
Large diffs are not rendered by default.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
2 changes: 1 addition & 1 deletionapplications/applications.c
This file contains hidden or 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
2 changes: 1 addition & 1 deletionapplications/applications.mk
This file contains hidden or 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 |
|---|---|---|
| @@ -451,4 +451,4 @@ endif | ||
| SRV_STORAGE ?= 0 | ||
| ifeq ($(SRV_STORAGE), 1) | ||
| CFLAGS+= -DSRV_STORAGE | ||
| endif | ||
58 changes: 52 additions & 6 deletionsscripts/User/ReadMe.md
This file contains hidden or 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 |
|---|---|---|
| @@ -1,23 +1,69 @@ | ||
| ##################################### | ||
| encode.py | ||
| decode.py | ||
| iconencode.py | ||
| icondecode.py | ||
| A set of python3 scripts for processing the Flipper image files. | ||
| These work as-is but I am rolling in improvements. | ||
| ##################################### | ||
| PREREQUISITES | ||
| You'll need heatshrink installed - a small embedded/RTOS compression and decompression library | ||
| You can get that here https://github.com/atomicobject/heatshrink | ||
| ##################################### | ||
| HOW TO USE | ||
| ## | ||
| # decode. | ||
| Decode a .mb into .xbm: | ||
| decode.py input_image output_image [width] [height] | ||
| Dimensions are not stored in .bm so you need to specify | ||
| If you have the meta.txt available for the animation set the dimensions will be in here. | ||
| It may also be part of the directory name for the animation files as well. | ||
| If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. | ||
| ## | ||
| # encode | ||
| Encode an .xbm file into .xb | ||
| encode.py input_image output_image | ||
| You will also get the image dimensions for use in meta.txt | ||
| That's it. | ||
| ## | ||
| # iconencode | ||
| Compress an icon asset from an XBM to a compressed char array ready to paste | ||
| Will assume dimensions of 128x64 | ||
| Header works like this, you'll have to do this manually for now! | ||
| Image Header Format Example | ||
| 0x01 = Compressed | ||
| 0x00 = Reserved Section | ||
| 0xa4,0x01 = 0x1a4, or, 420 - the size of the compressed array, minus this header. Just count the commas ;) | ||
| Rest of the data is char array output from heatshrink of the original XBM char array. | ||
| Calculated Header: 0x01,0x00,0xa4,0x01 | ||
| from furi_hal_compress.c: | ||
| typedef struct { | ||
| uint8_t is_compressed; | ||
| uint8_t reserved; | ||
| uint16_t compressed_buff_size; | ||
| } FuriHalCompressHeader; | ||
| ## | ||
| # icondecode | ||
| Decompress an icon asset (as found in assets_icons.c and elsewhere) | ||
| icondecodepy input_image output_image [trim] [width] [height] | ||
| The icons in this file have a different header format. This will need to be trimmed. | ||
| A value of 8 for trim appears to be correct. | ||
| As with regular decoding, the width and height are not listed - but can be found in code/const/variable/etc names. | ||
| copy just the char array. The script does not care if the curly braces or semicolon are in place. | ||
| i.e. the following are all acceptable and equivalent. | ||
| {0x00,0x08,0x1C,0x3E,0x7F,}; | ||
| {0x00,0x08,0x1C,0x3E,0x7F,} | ||
| 0x00,0x08,0x1C,0x3E,0x7F | ||
6 changes: 4 additions & 2 deletionsscripts/User/decode.py
This file contains hidden or 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
6 changes: 6 additions & 0 deletionsscripts/User/encode.py
This file contains hidden or 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
65 changes: 65 additions & 0 deletionsscripts/User/icondecode.py
This file contains hidden or 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,65 @@ | ||
| import logging | ||
| import argparse | ||
| import subprocess | ||
| import io | ||
| import os | ||
| import sys | ||
| def padded_hex(i, l): | ||
| given_int = i | ||
| given_len = l | ||
| hex_result = hex(given_int)[2:] # remove '0x' from beginning of str | ||
| num_hex_chars = len(hex_result) | ||
| extra_zeros = '0' * (given_len - num_hex_chars) # may not get used.. | ||
| return ('0x' + hex_result if num_hex_chars == given_len else | ||
| '?' * given_len if num_hex_chars > given_len else | ||
| '0x' + extra_zeros + hex_result if num_hex_chars < given_len else | ||
| None) | ||
| parser = argparse.ArgumentParser(description='Turn icon char arrays back into .xbm') | ||
| parser.add_argument('infile', metavar='i', | ||
| help='Input file') | ||
| parser.add_argument('outfile', metavar='o', | ||
| help='File to write to') | ||
| parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", | ||
| help='Width of the image. Find from meta.txt or directory name') | ||
| parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", | ||
| help='Height of the image. Find from meta.txt or directory name') | ||
| parser.add_argument('Trim', metavar='T', type=int, nargs="?", default="8", | ||
| help='Number of bytes off the start/header to trim. Multiples of 2 required.') | ||
| args = vars(parser.parse_args()) | ||
| r = open(args["infile"],"r") | ||
| w = open(args["outfile"],"w") | ||
| imageWidth=args["Width"] | ||
| imageHeight=args["Height"] | ||
| trimStart=args["Trim"] | ||
| output = subprocess.check_output(["cat", args["infile"]]) #yes this is terrible. | ||
| f = io.StringIO(output.decode().strip()) | ||
| data = f.read().strip().replace(";","").replace("{","").replace("}","") | ||
| data_str = data.replace(",", "").replace("0x", "") | ||
| data_bin = bytearray.fromhex(data_str[trimStart:]) | ||
| data_decoded_str = subprocess.check_output( | ||
| ["heatshrink", "-d","-w8","-l4"], input=data_bin | ||
| ) | ||
| b=list(data_decoded_str) | ||
| c=', '.join(padded_hex(my_int,2) for my_int in b) | ||
| width_out = "#define icon_width "+ str(imageWidth) + "\n" | ||
| height_out = "#define icon_height "+ str(imageHeight) + "\n" | ||
| bytes_out = "static unsigned char icon_bits[] = {"+ str(c) + "};" | ||
| data=width_out+height_out+bytes_out | ||
| w.write(data) | ||
| r.close() | ||
| w.close() |
68 changes: 68 additions & 0 deletionsscripts/User/iconencode.py
This file contains hidden or 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,68 @@ | ||
| import logging | ||
| import argparse | ||
| import subprocess | ||
| import io | ||
| import os | ||
| import sys | ||
| def padded_hex(i, l): | ||
| given_int = i | ||
| given_len = l | ||
| hex_result = hex(given_int)[2:] # remove '0x' from beginning of str | ||
| num_hex_chars = len(hex_result) | ||
| extra_zeros = '0' * (given_len - num_hex_chars) # may not get used.. | ||
| return ('0x' + hex_result if num_hex_chars == given_len else | ||
| '?' * given_len if num_hex_chars > given_len else | ||
| '0x' + extra_zeros + hex_result if num_hex_chars < given_len else | ||
| None) | ||
| parser = argparse.ArgumentParser(description='Turn icon char arrays back into .xbm') | ||
| parser.add_argument('infile', metavar='i', | ||
| help='Input file') | ||
| parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", | ||
| help='Width of the image. Find from meta.txt or directory name') | ||
| parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", | ||
| help='Height of the image. Find from meta.txt or directory name') | ||
| args = vars(parser.parse_args()) | ||
| r = open(args["infile"],"r") | ||
| infile=args["infile"].split(".")[0] | ||
| imageWidth=args["Width"] | ||
| imageHeight=args["Height"] | ||
| dims=str(imageWidth)+"x"+str(imageHeight) | ||
| output = subprocess.check_output(["cat", args["infile"]]) #yes this is terrible. | ||
| f = io.StringIO(output.decode().strip()) | ||
| data = f.read().strip().replace(";","").replace("{","").replace("}","") | ||
| data_str = data.replace(",", "").replace("0x", "") | ||
| data_bin = bytearray.fromhex(data_str) | ||
| data_encoded_str = subprocess.check_output( | ||
| ["heatshrink", "-e","-w8","-l4"], input=data_bin | ||
| ) | ||
| b=list(data_encoded_str) | ||
| c=','.join(padded_hex(my_int,2) for my_int in b) | ||
| # a bit ugly. | ||
| framename="_I_"+infile+"_"+dims | ||
| print(len(b)) | ||
| #d=len(b) | ||
| # if b > 255 split 0x1234 into 0x34,0x12 | ||
| #d=hex(len(b)) | ||
| char_out = "const uint8_t "+framename+"_0[] = {"+ str(c) + ",};" | ||
| char_out2 = "const uint8_t "+framename+"[] = {"+framename+"_0};" | ||
| #data=bytes_out | ||
| print(char_out) | ||
| print(char_out2) | ||
| #w.write(data) | ||
| #w.close() |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.