Skip to content

Commit fe8798a

Browse files
committed
Synchronize some of the code for the latest smoothieware project
1 parent 98563f2 commit fe8798a

File tree

11 files changed

+445
-87
lines changed

11 files changed

+445
-87
lines changed

src/libs/MemoryPool.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void operator delete(void* p)
2626
}
2727

2828

29-
#define offset(x) (((uint8_t*) x) - ((uint8_t*) this->base))
29+
#define offset(x) ((uint32_t)(((uint8_t*) x) - ((uint8_t*) this->base)))
3030

3131
typedef struct __attribute__ ((packed))
3232
{
@@ -129,7 +129,7 @@ void* MemoryPool::alloc(size_t nbytes)
129129
p = (_poolregion*) (((uint8_t*) p) + p->next);
130130

131131
// make sure we don't walk off the end
132-
} while (p <= (_poolregion*) (((uint8_t*)base) + size));
132+
} while (p < (_poolregion*) (((uint8_t*)base) + size));
133133

134134
// fell off the end of the region!
135135
return NULL;
@@ -144,6 +144,11 @@ void MemoryPool::dealloc(void* d)
144144

145145
// combine next block if it's free
146146
_poolregion* q = (_poolregion*) (((uint8_t*) p) + p->next);
147+
if(q >= (_poolregion*) (((uint8_t*) base) + size)) {
148+
// we are beyond the end of the pool, ie last block
149+
return;
150+
}
151+
147152
if (q->used == 0)
148153
{
149154
MDEBUG("\t\tCombining with next free region at %p, new size is %d\n", q, p->next + q->next);
@@ -173,7 +178,7 @@ void MemoryPool::dealloc(void* d)
173178
q->next += p->next;
174179

175180
// sanity check
176-
if ((offset(p) + p->next) >= size)
181+
if ((offset(p) + p->next) > size)
177182
{
178183
// captain, we have a problem!
179184
// this can only happen if something has corrupted our heap, since we should simply fail to find a free block if it's full
@@ -208,7 +213,7 @@ void MemoryPool::debug(StreamOutput* str)
208213
uint32_t free = 0;
209214
str->printf("Start: %ub MemoryPool at %p\n", size, p);
210215
do {
211-
str->printf("\tChunk at %p (%+4d): %s, %lu bytes\n", p, offset(p), (p->used?"used":"free"), p->next);
216+
str->printf("\tChunk at %p (%4lu): %s, %lu bytes\n", p, offset(p), (p->used?"used":"free"), p->next);
212217
tot += p->next;
213218
if (p->used == 0)
214219
free += p->next;

src/libs/USBDevice/targets/TARGET_STM/USBHAL_IP_OTGFSHS.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
#endif
2727
#endif
2828

29+
30+
/* Begin by Yanminge 2019-02-21 */
2931
#if defined(TARGET_DISCO_F429ZI) || \
3032
defined(TARGET_DISCO_F769NI) || \
31-
/* Begin by Yanminge 2019-02-21 */
3233
defined(TARGET_DISCO_F746NG_OTG_HS) || \
3334
defined(TARGET_TEST_F407ZG)
3435
/* End by Yanminge 2019-02-21 */

src/libs/USBDevice/targets/TARGET_STM/USBHAL_STM32.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#ifndef USBHAL_STM32_H
1919
#define USBHAL_STM32_H
2020

21+
/* Begin by Yanminge 2019-02-21 */
2122
#if defined(TARGET_NUCLEO_F207ZG) || \
2223
defined(TARGET_NUCLEO_F401RE) || \
2324
defined(TARGET_STEVAL_3DP001V1) || \
@@ -30,9 +31,7 @@
3031
defined(TARGET_NUCLEO_F767ZI) || \
3132
defined(TARGET_NUCLEO_F746ZG) || \
3233
defined(TARGET_DISCO_F407VG) || \
33-
/* Begin by Yanminge 2019-02-21 */
34-
defined(TARGET_TEST_F407ZG) || \
35-
/* End by Yanminge 2019-02-21 */
34+
defined(TARGET_TEST_F407ZG) || \
3635
defined(TARGET_DISCO_F413ZH) || \
3736
defined(TARGET_DISCO_F429ZI) || \
3837
defined(TARGET_DISCO_F469NI) || \
@@ -41,6 +40,7 @@
4140
defined(TARGET_DISCO_L475VG_IOT01A) || \
4241
defined(TARGET_DISCO_L476VG)
4342
#include "USBHAL_IP_OTGFSHS.h"
43+
/* End by Yanminge 2019-02-21 */
4444

4545
#elif defined(TARGET_NUCLEO_F103RB) || \
4646
defined(TARGET_NUCLEO_F303ZE) || \

src/modules/communication/GcodeDispatch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ void GcodeDispatch::on_console_line_received(void *line)
8686
//Get linenumber
8787
if ( first_char == 'N' ) {
8888
Gcode full_line = Gcode(possible_command, new_message.stream, false);
89-
ln = (int) full_line.get_value('N');
90-
int chksum = (int) full_line.get_value('*');
89+
ln = (int) full_line.get_int('N');
90+
int chksum = (int) full_line.get_int('*');
9191

9292
//Catch message if it is M110: Set Current Line Number
9393
if ( full_line.has_m ) {

src/modules/utils/panel/bitmaps.h

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#pragma once
2+
3+
#include <stdint.h>
4+
5+
/**
6+
* Icons
7+
*
8+
* Made with Marlin Bitmap Converter
9+
* http://marlinfw.org/tools/u8glib/converter.html
10+
*
11+
* This bitmap from the file 'firmware-logo.png'
12+
*/
13+
14+
#define icon_width 8
15+
#define icon_height 8
16+
17+
static const uint8_t hotend_icon[] = {
18+
0x7C, // .#####..
19+
0x10, // ...#....
20+
0x7C, // .#####..
21+
0x10, // ...#....
22+
0x38, // ..###...
23+
0x38, // ..###...
24+
0x10, // ...#....
25+
0x00 // ........
26+
};
27+
28+
static const uint8_t bed_icon[] = {
29+
0x24, // ..#..#..
30+
0x48, // .#..#...
31+
0x24, // ..#..#..
32+
0x48, // .#..#...
33+
0x24, // ..#..#..
34+
0x00, // ........
35+
0xFE, // #######.
36+
0x00 // ........
37+
};
38+
39+
static const uint8_t fan_icon[] = {
40+
0x00, // ........
41+
0x4C, // .#..##..
42+
0x68, // .##.#...
43+
0x10, // ...#....
44+
0x2C, // ..#.##..
45+
0x64, // .##..#..
46+
0x00, // ........
47+
0x00 // ........
48+
};
49+
50+
static const uint8_t speed_icon[] = {
51+
0x90, // #..#....
52+
0x48, // .#..#...
53+
0x24, // ..#..#..
54+
0x12, // ...#..#.
55+
0x24, // ..#..#..
56+
0x48, // .#..#...
57+
0x90, // #..#....
58+
0x00 // ........
59+
};
60+
61+
static const uint8_t time_icon[] = {
62+
0x38, // ..###...
63+
0x44, // .#...#..
64+
0x92, // #..#..#.
65+
0x9E, // #..####.
66+
0x82, // #.....#.
67+
0x44, // .#...#..
68+
0x38, // ..###...
69+
0x00 // ........
70+
};
71+
72+
// TODO: Remove once new watch screen is supported on all displays
73+
static const uint8_t large_icons[] = { // 16x80 - he1, he2, he3, bed, fan
74+
0x3f, 0xfc, 0x3f, 0xfc, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0x7f, 0x7f, 0x7e, 0x3f, 0x7c, 0x1f,
75+
0x78, 0x0f, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80,
76+
0x01, 0x80, 0x3f, 0xfc, 0x3f, 0xfc, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0x7f, 0x7c, 0x7e, 0x3d,
77+
0xfc, 0x1c, 0x78, 0x0f, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80,
78+
0x01, 0x80, 0x01, 0x80, 0x3f, 0xfc, 0x3f, 0xfc, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0x7f, 0x7c,
79+
0x7e, 0x3f, 0x7c, 0x1c, 0x78, 0x0f, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01, 0x80, 0x00, 0x00,
80+
0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x08, 0x88, 0x11, 0x10, 0x22, 0x20, 0x22,
81+
0x20, 0x11, 0x10, 0x08, 0x88, 0x04, 0x44, 0x04, 0x44, 0x08, 0x88, 0x11, 0x10, 0x22, 0x20,
82+
0x00, 0x00, 0x7f, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0x39, 0xec, 0x43, 0xe2, 0x9b, 0xc9, 0xa3,
83+
0x85, 0x03, 0x85, 0xc3, 0x00, 0xe0, 0x3e, 0xf9, 0xbf, 0xfd, 0x9f, 0x7c, 0x07, 0x00, 0xc3,
84+
0xa1, 0xc0, 0xa1, 0xc5, 0x93, 0xd9, 0x47, 0xc2, 0x37, 0x9c
85+
};

src/modules/utils/panel/panels/LcdBase.h

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,83 @@ class LcdBase {
5353
virtual void setLedBrightness(int led, int val){};
5454
virtual void buzz(long,uint16_t){};
5555
virtual bool hasGraphics() { return false; }
56+
virtual bool hasFullGraphics() { return false; } // Temporary. Remove this once RRDGLCD has more graphics functions implemented.
5657
virtual bool encoderReturnsDelta() { return false; } // set to true if the panel handles encoder clicks and returns a delta
5758
virtual uint8_t getContrast() { return 0; }
5859
virtual void setContrast(uint8_t c) { }
5960

61+
// Graphics Functions
6062
// on graphics panels, the input bitmap is in X windows XBM format but
6163
// with the bits in a byte reversed so bit7 is left most and bit0 is
6264
// right most. x_offset must by byte aligned if used
6365
virtual void bltGlyph(int x, int y, int w, int h, const uint8_t *glyph, int span= 0, int x_offset=0, int y_offset=0){}
66+
67+
/**
68+
* Sets the exact position of the text cursor on graphical displays. Takes the coordinates of the top left
69+
* of the next character to be printed. Not used for text-only displays.
70+
*
71+
* @param x X coordinate
72+
* @param y Y coordinate
73+
*/
74+
virtual void setCursorPX(int x, int y) {};
75+
76+
/**
77+
* Sets the mode used for drawing the foreground when printing text.
78+
*
79+
* @param c 0: Turn pixels off (AND logic)
80+
* 1: Turn pixels on (OR logic) (default)
81+
* 2: Invert pixels (XOR logic)
82+
*/
83+
virtual void setColor(int c) {};
84+
85+
/**
86+
* Turns on/off drawing the background behind text. If on, the background color will be the inverse of the text color.
87+
* If off the background will be transparent. Defaults to on.
88+
*
89+
* @param bg True: Background on (default), False: Background off (transparent)
90+
*/
91+
virtual void setBackground(bool bg) {};
92+
93+
/**
94+
* Turns on/off a specific pixel on the display. The screen origin (0,0) is at the top left of the display.
95+
*
96+
* @param x X coordinate
97+
* @param y Y coordinate
98+
* @param color Mode to use for drawing the pixel (see setColor() for options)
99+
*/
100+
virtual void pixel(int x, int y, int color = 1) {};
101+
102+
/**
103+
* Draws a horizontal line.
104+
*
105+
* @param x X coordinate of start of line
106+
* @param y Y coordinate of start of line
107+
* @param w Width of the line
108+
* @param color Mode to use for drawing (see setColor() for options)
109+
*/
110+
virtual void drawHLine(int x, int y, int w, int color = 1) {};
111+
112+
/**
113+
* Draws a vertical line.
114+
*
115+
* @param x X coordinate of start of line
116+
* @param y Y coordinate of start of line
117+
* @param h Height of the line
118+
* @param color Mode to use for drawing (see setColor() for options)
119+
*/
120+
virtual void drawVLine(int x, int y, int h, int color = 1) {};
121+
122+
/**
123+
* Draws a filled rectangle.
124+
*
125+
* @param x X coordinate of left side
126+
* @param y Y coordinate of top
127+
* @param w Width of rectangle
128+
* @param h Height of rectangle
129+
* @param color Mode to use for drawing (see setColor() for options)
130+
*/
131+
virtual void drawBox(int x, int y, int w, int h, int color = 1) {};
132+
64133
// only used on certain panels
65134
virtual void on_refresh(bool now= false){};
66135
virtual void on_main_loop(){};

0 commit comments

Comments
 (0)