Fix out oderso, implement menu scrolling i guess

This commit is contained in:
Jan-Henrik 2020-02-04 23:38:50 +01:00
parent 85d1144261
commit 54c4538a7a
6 changed files with 43605 additions and 37 deletions

View file

@ -6,6 +6,9 @@
void Menu::render(u8g2_t* u8g2_, uint8_t xStart, uint8_t yStart, uint8_t width, uint8_t height)
{
this->width = width;
this->height = height;
uint8_t maxVisibleItems = height / MENU_ITEM_HEIGHT;
uint8_t itemsToRender = std::min(maxVisibleItems, uint8_t(this->itemCount - currentScrollStart));
@ -29,3 +32,34 @@ void Menu::render(u8g2_t* u8g2_, uint8_t xStart, uint8_t yStart, uint8_t width,
u8g2_DrawStr(u8g2_, xStart + width - valueStringWidth, yPosition + MENU_ITEM_HEIGHT, item->get_string_representation());
}
}
void Menu::up()
{
if (this->selectedItem > 0) {
if (this->selectedItem - this->currentScrollStart == 1) { // keep scroll start one up
this->currentScrollStart--;
}
this->selectedItem--;
if (this->selectedItem == 0) {
this->currentScrollStart = 0;
}
}
}
void Menu::down()
{
uint8_t maxVisibleItems = height / MENU_ITEM_HEIGHT;
if (this->selectedItem < this->itemCount - 1) {
if (this->selectedItem - this->currentScrollStart == maxVisibleItems - 1) {
this->currentScrollStart++;
}
this->selectedItem++;
if (this->selectedItem >= this->itemCount - 1 - maxVisibleItems) { // last item
this->currentScrollStart = this->itemCount - 1 - maxVisibleItems;
}
}
}

View file

@ -13,12 +13,15 @@ class Menu {
uint8_t selectedItem;
uint8_t currentScrollStart; // index we start rendering the menu from (for scrolling)
int8_t currentEditingItem;
uint8_t width, height;
public:
Menu()
Menu(uint8_t width_, uint8_t height_)
: selectedItem(0)
, currentScrollStart(0)
, currentEditingItem(-1) {};
, currentEditingItem(-1)
, width(width_)
, height(height_) {};
void up();
void down();

View file

@ -3,7 +3,7 @@
<eagle version="9.5.2">
<drawing>
<settings>
<setting alwaysvectorfont="yes"/>
<setting alwaysvectorfont="no"/>
<setting verticaltext="up"/>
</settings>
<grid distance="50" unitdist="mil" unit="mm" style="lines" multiple="1" display="no" altdistance="5" altunitdist="mil" altunit="mil"/>
@ -1536,7 +1536,7 @@ KEMET S / EIA 3216-12</description>
</packages3d>
</library>
<library name="transistor" urn="urn:adsk.eagle:library:402">
<description>&lt;b&gt;Transistors&lt;/b&gt;&lt;p&gt;
<description>&lt;b&gt;Transistors&lt;/b&gt;&lt;p&gt;
&lt;author&gt;Created by librarian@cadsoft.de&lt;/author&gt;</description>
<packages>
<package name="SOT23-BEC" urn="urn:adsk.eagle:footprint:28685/1" library_version="7">
@ -2205,7 +2205,6 @@ Please make sure your boards conform to these design rules.
<contactref element="U1" pad="7"/>
<contactref element="R19" pad="1"/>
<contactref element="D1" pad="A"/>
<contactref element="D2" pad="A"/>
<contactref element="C5" pad="2"/>
<contactref element="R8" pad="2"/>
<wire x1="48.006" y1="38.1762" x2="50.292" y2="38.1762" width="0.254" layer="1"/>
@ -2213,7 +2212,6 @@ Please make sure your boards conform to these design rules.
<wire x1="48.006" y1="38.1762" x2="47.99" y2="38.1" width="0.254" layer="1"/>
<wire x1="48.006" y1="38.0619" x2="48.006" y2="37.2618" width="0.254" layer="1"/>
<wire x1="48.006" y1="37.2618" x2="48.006" y2="34.29" width="0.254" layer="1"/>
<wire x1="48.006" y1="34.29" x2="47.99" y2="34.29" width="0.254" layer="1"/>
<wire x1="48.006" y1="38.0619" x2="47.99" y2="38.1" width="0.254" layer="1"/>
<wire x1="21.717" y1="38.6334" x2="24.1173" y2="38.6334" width="0.254" layer="1"/>
<wire x1="24.1173" y1="38.6334" x2="24.13" y2="38.6" width="0.254" layer="1"/>
@ -2226,21 +2224,20 @@ Please make sure your boards conform to these design rules.
<wire x1="27.0891" y1="39.2049" x2="35.5473" y2="39.2049" width="0.254" layer="1"/>
<wire x1="26.7462" y1="38.862" x2="27.0891" y2="39.2049" width="0.254" layer="1"/>
<wire x1="26.7462" y1="38.862" x2="26.67" y2="38.75" width="0.254" layer="1"/>
<contactref element="D2" pad="C"/>
<wire x1="48.006" y1="34.29" x2="45.99" y2="34.29" width="0" layer="19" extent="1-1"/>
</signal>
<signal name="N$2">
<contactref element="U2" pad="7"/>
<contactref element="R21" pad="1"/>
<contactref element="D3" pad="A"/>
<contactref element="D4" pad="A"/>
<contactref element="R10" pad="2"/>
<contactref element="C4" pad="2"/>
<wire x1="48.006" y1="28.0035" x2="50.292" y2="28.0035" width="0.254" layer="1"/>
<wire x1="50.292" y1="28.0035" x2="50.3" y2="27.94" width="0.254" layer="1"/>
<wire x1="48.006" y1="28.0035" x2="47.99" y2="27.94" width="0.254" layer="1"/>
<wire x1="48.006" y1="27.8892" x2="48.006" y2="27.2034" width="0.254" layer="1"/>
<wire x1="48.006" y1="27.2034" x2="48.006" y2="24.2316" width="0.254" layer="1"/>
<wire x1="48.006" y1="24.2316" x2="47.99" y2="24.13" width="0.254" layer="1"/>
<wire x1="48.006" y1="27.8892" x2="47.99" y2="27.94" width="0.254" layer="1"/>
<wire x1="26.5176" y1="28.4607" x2="24.2316" y2="28.4607" width="0.254" layer="1"/>
<wire x1="26.6319" y1="28.575" x2="26.5176" y2="28.4607" width="0.254" layer="1"/>
<wire x1="24.2316" y1="28.4607" x2="24.13" y2="28.44" width="0.254" layer="1"/>
@ -2254,6 +2251,9 @@ Please make sure your boards conform to these design rules.
<wire x1="27.0891" y1="29.0322" x2="35.5473" y2="29.0322" width="0.254" layer="1"/>
<wire x1="26.7462" y1="28.6893" x2="27.0891" y2="29.0322" width="0.254" layer="1"/>
<wire x1="26.7462" y1="28.6893" x2="26.67" y2="28.59" width="0.254" layer="1"/>
<contactref element="D4" pad="C"/>
<wire x1="48.006" y1="27.8892" x2="48.006" y2="28.0035" width="0" layer="19" extent="1-1"/>
<wire x1="45.99" y1="27.94" x2="48.006" y2="28.0035" width="0" layer="19" extent="1-1"/>
</signal>
<signal name="N$3">
<contactref element="R7" pad="2"/>
@ -3124,13 +3124,8 @@ Please make sure your boards conform to these design rules.
<contactref element="C18" pad="2"/>
<contactref element="C19" pad="2"/>
<contactref element="C20" pad="2"/>
<contactref element="D4" pad="C"/>
<contactref element="D2" pad="C"/>
<contactref element="D6" pad="A"/>
<contactref element="C10" pad="-"/>
<wire x1="45.9486" y1="34.29" x2="45.9486" y2="28.0035" width="0.4064" layer="1"/>
<wire x1="45.9486" y1="28.0035" x2="45.99" y2="27.94" width="0.4064" layer="1"/>
<wire x1="45.9486" y1="34.29" x2="45.99" y2="34.29" width="0.4064" layer="1"/>
<wire x1="38.862" y1="51.0921" x2="38.862" y2="49.6062" width="0.4064" layer="1"/>
<wire x1="39.2049" y1="51.435" x2="38.862" y2="51.0921" width="0.4064" layer="1"/>
<wire x1="38.862" y1="49.6062" x2="38.75" y2="49.53" width="0.4064" layer="1"/>
@ -3149,7 +3144,6 @@ Please make sure your boards conform to these design rules.
<wire x1="40.005" y1="36.6903" x2="42.291" y2="34.4043" width="0.4064" layer="1"/>
<wire x1="40.005" y1="41.0337" x2="40.005" y2="36.6903" width="0.4064" layer="16"/>
<wire x1="37.8333" y1="43.2054" x2="40.005" y2="41.0337" width="0.4064" layer="16"/>
<wire x1="45.8343" y1="34.4043" x2="45.99" y2="34.29" width="0.4064" layer="1"/>
<wire x1="40.3479" y1="9.6012" x2="40.3479" y2="12.6873" width="0.4064" layer="1"/>
<wire x1="39.6621" y1="8.9154" x2="40.3479" y2="9.6012" width="0.4064" layer="1"/>
<wire x1="40.3479" y1="12.6873" x2="40.435" y2="12.7" width="0.4064" layer="1"/>
@ -3191,6 +3185,10 @@ Please make sure your boards conform to these design rules.
<via x="16.002" y="32.4612" extent="1-16" drill="0.3048"/>
<via x="16.002" y="25.146" extent="1-16" drill="0.3048"/>
<via x="38.9763" y="13.9446" extent="1-16" drill="0.3048"/>
<contactref element="D4" pad="A"/>
<contactref element="D2" pad="A"/>
<wire x1="45.8343" y1="34.4043" x2="47.99" y2="34.29" width="0" layer="19" extent="1-1"/>
<wire x1="47.99" y1="27.94" x2="47.99" y2="34.29" width="0" layer="19" extent="1-1"/>
</signal>
<signal name="N$40">
<contactref element="JP14" pad="2"/>

View file

@ -12273,7 +12273,7 @@ Source: http://products.nichicon.co.jp/en/pdf/XJA043/e-ud.pdf</description>
</devicesets>
</library>
<library name="transistor" urn="urn:adsk.eagle:library:402">
<description>&lt;b&gt;Transistors&lt;/b&gt;&lt;p&gt;
<description>&lt;b&gt;Transistors&lt;/b&gt;&lt;p&gt;
&lt;author&gt;Created by librarian@cadsoft.de&lt;/author&gt;</description>
<packages>
<package name="TO3" urn="urn:adsk.eagle:footprint:29823/1" library_version="7">
@ -13428,7 +13428,7 @@ http://www.ee.siue.edu/~alozows/library/datasheets/BFR96.pdf</description>
</symbols>
<devicesets>
<deviceset name="*-NPN-" urn="urn:adsk.eagle:component:30081/24" prefix="T" uservalue="yes" library_version="7">
<description>NPN Transistror&lt;p&gt;
<description>NPN Transistror&lt;p&gt;
BF959 corrected 2008.03.06&lt;br&gt;</description>
<gates>
<gate name="G$1" symbol="NPN" x="0" y="0"/>
@ -14885,17 +14885,17 @@ BF959 corrected 2008.03.06&lt;br&gt;</description>
<attribute name="NAME" x="139.7" y="71.12" size="1.27" layer="95" rot="R90"/>
<attribute name="VALUE" x="146.05" y="71.12" size="1.27" layer="96" rot="R90"/>
</instance>
<instance part="D2" gate="G$1" x="142.24" y="58.42" smashed="yes" rot="R270">
<attribute name="NAME" x="144.78" y="60.96" size="1.27" layer="95" rot="R270"/>
<attribute name="VALUE" x="138.43" y="60.96" size="1.27" layer="96" rot="R270"/>
<instance part="D2" gate="G$1" x="142.24" y="58.42" smashed="yes" rot="R90">
<attribute name="NAME" x="139.7" y="55.88" size="1.27" layer="95" rot="R90"/>
<attribute name="VALUE" x="146.05" y="55.88" size="1.27" layer="96" rot="R90"/>
</instance>
<instance part="D3" gate="G$1" x="142.24" y="33.02" smashed="yes" rot="R90">
<attribute name="NAME" x="139.7" y="30.48" size="1.27" layer="95" rot="R90"/>
<attribute name="VALUE" x="146.05" y="30.48" size="1.27" layer="96" rot="R90"/>
</instance>
<instance part="D4" gate="G$1" x="142.24" y="17.78" smashed="yes" rot="R270">
<attribute name="NAME" x="144.78" y="20.32" size="1.27" layer="95" rot="R270"/>
<attribute name="VALUE" x="138.43" y="20.32" size="1.27" layer="96" rot="R270"/>
<instance part="D4" gate="G$1" x="142.24" y="17.78" smashed="yes" rot="R90">
<attribute name="NAME" x="139.7" y="15.24" size="1.27" layer="95" rot="R90"/>
<attribute name="VALUE" x="146.05" y="15.24" size="1.27" layer="96" rot="R90"/>
</instance>
<instance part="GND1" gate="1" x="10.16" y="66.04" smashed="yes">
<attribute name="VALUE" x="7.62" y="63.5" size="1.778" layer="96"/>
@ -15138,8 +15138,6 @@ BF959 corrected 2008.03.06&lt;br&gt;</description>
<wire x1="142.24" y1="66.04" x2="152.4" y2="66.04" width="0.1524" layer="91"/>
<wire x1="142.24" y1="71.12" x2="142.24" y2="66.04" width="0.1524" layer="91"/>
<junction x="142.24" y="66.04"/>
<pinref part="D2" gate="G$1" pin="A"/>
<wire x1="142.24" y1="60.96" x2="142.24" y2="66.04" width="0.1524" layer="91"/>
<pinref part="C5" gate="G$1" pin="2"/>
<wire x1="116.84" y1="83.82" x2="124.46" y2="83.82" width="0.1524" layer="91"/>
<wire x1="124.46" y1="83.82" x2="124.46" y2="78.74" width="0.1524" layer="91"/>
@ -15148,6 +15146,8 @@ BF959 corrected 2008.03.06&lt;br&gt;</description>
<wire x1="124.46" y1="78.74" x2="124.46" y2="66.04" width="0.1524" layer="91"/>
<wire x1="119.38" y1="78.74" x2="124.46" y2="78.74" width="0.1524" layer="91"/>
<junction x="124.46" y="78.74"/>
<pinref part="D2" gate="G$1" pin="C"/>
<wire x1="142.24" y1="60.96" x2="142.24" y2="66.04" width="0.1524" layer="91"/>
</segment>
</net>
<net name="N$2" class="0">
@ -15159,8 +15159,6 @@ BF959 corrected 2008.03.06&lt;br&gt;</description>
<wire x1="142.24" y1="25.4" x2="152.4" y2="25.4" width="0.1524" layer="91"/>
<wire x1="142.24" y1="30.48" x2="142.24" y2="25.4" width="0.1524" layer="91"/>
<junction x="142.24" y="25.4"/>
<pinref part="D4" gate="G$1" pin="A"/>
<wire x1="142.24" y1="20.32" x2="142.24" y2="25.4" width="0.1524" layer="91"/>
<pinref part="R10" gate="G$1" pin="2"/>
<wire x1="119.38" y1="38.1" x2="121.92" y2="38.1" width="0.1524" layer="91"/>
<wire x1="121.92" y1="38.1" x2="121.92" y2="25.4" width="0.1524" layer="91"/>
@ -15169,6 +15167,8 @@ BF959 corrected 2008.03.06&lt;br&gt;</description>
<wire x1="116.84" y1="43.18" x2="121.92" y2="43.18" width="0.1524" layer="91"/>
<wire x1="121.92" y1="43.18" x2="121.92" y2="38.1" width="0.1524" layer="91"/>
<junction x="121.92" y="38.1"/>
<pinref part="D4" gate="G$1" pin="C"/>
<wire x1="142.24" y1="20.32" x2="142.24" y2="25.4" width="0.1524" layer="91"/>
</segment>
</net>
<net name="N$3" class="0">
@ -15879,16 +15879,6 @@ BF959 corrected 2008.03.06&lt;br&gt;</description>
<junction x="246.38" y="-86.36"/>
</segment>
<segment>
<pinref part="P-2" gate="1" pin="-12V"/>
<pinref part="D4" gate="G$1" pin="C"/>
<wire x1="142.24" y1="12.7" x2="142.24" y2="15.24" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="P-3" gate="1" pin="-12V"/>
<pinref part="D2" gate="G$1" pin="C"/>
<wire x1="142.24" y1="53.34" x2="142.24" y2="55.88" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="D6" gate="G$1" pin="A"/>
<wire x1="139.7" y1="-83.82" x2="142.24" y2="-83.82" width="0.1524" layer="91"/>
<wire x1="142.24" y1="-83.82" x2="142.24" y2="-86.36" width="0.1524" layer="91"/>
@ -15899,6 +15889,16 @@ BF959 corrected 2008.03.06&lt;br&gt;</description>
<wire x1="144.78" y1="-88.9" x2="144.78" y2="-86.36" width="0.1524" layer="91"/>
<junction x="144.78" y="-86.36"/>
</segment>
<segment>
<pinref part="P-2" gate="1" pin="-12V"/>
<pinref part="D4" gate="G$1" pin="A"/>
<wire x1="142.24" y1="12.7" x2="142.24" y2="15.24" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="P-3" gate="1" pin="-12V"/>
<pinref part="D2" gate="G$1" pin="A"/>
<wire x1="142.24" y1="53.34" x2="142.24" y2="55.88" width="0.1524" layer="91"/>
</segment>
</net>
<net name="N$40" class="0">
<segment>

View file

@ -0,0 +1,47 @@
width = 75;
panel_width = 76.2;
thickness = 2;
jack_radius = 6.2 / 2;
pot_radius = 9.1 / 2;
led_radius = 5.1 / 2;
switch_radius = 5.1 / 2;
x_offset = (128.5 - 100) / 2;
y_offset = (panel_width - width) / 2;
jacks = [[6.35, 91.44], [6.35, 74.93], [6.35, 58.42], [6.35, 41.91], [6.35, 22.352], [6.35, 7.62],
[19.05, 91.44], [19.05, 74.93], [19.05, 58.42], [19.05, 41.91], [19.05, 22.352], [19.05, 7.62],
[31.75, 22.352], [31.75, 7.62],
[44.45, 22.352], [44.45, 7.62],
[64.77, 22.352], [64.77, 7.62]];
pots = [[44.7675, 91.44], [44.7675, 74.93], [44.7675, 58.42], [44.7675, 41.91],
[64.77, 91.44], [64.77, 74.93], [64.77, 58.42], [64.77, 41.91]];
leds = [];
switches = [];
difference() {
cube(size = [128.5, panel_width, thickness]);
for (jack = jacks)
translate([jack[1] + x_offset, jack[0]+y_offset, -thickness / 2]) linear_extrude(height = thickness * 2) circle(r = jack_radius, $fn = 50);
for (pot = pots)
translate([pot[1] + x_offset, pot[0]+y_offset, -thickness / 2]) linear_extrude(height = thickness * 2) circle(r = pot_radius, $fn = 50);
for (led = leds)
translate([led[1] + x_offset, led[0]+y_offset, -thickness / 2]) linear_extrude(height = thickness * 2) circle(r = led_radius, $fn = 50);
for (switch = switches)
translate([switch[1] + x_offset, switch[0]+y_offset, -thickness / 2]) linear_extrude(height = thickness * 2) circle(r = switch_radius, $fn = 50);
// top hole
translate([125.5, 7.5, -thickness / 2]) linear_extrude(height = thickness * 2) circle(r = 3.2 / 2, $fn = 10);
//bottom hole
translate([3, 7.5, -thickness / 2]) linear_extrude(height = thickness * 2) circle(r = 3.2 / 2, $fn = 100);
// top hole
translate([125.5, ((panel_width / 5.08) - 2) * 5.08, -thickness / 2]) linear_extrude(height = thickness * 2) circle(r = 3.2 / 2, $fn = 10);
//bottom hole
translate([3, ((panel_width / 5.08) - 2) * 5.08, -thickness / 2]) linear_extrude(height = thickness * 2) circle(r = 3.2 / 2, $fn = 100);
}

File diff suppressed because it is too large Load diff