\subsubsection{Using the network scripts}

To be able to access the network functions, you need to include
the necessary shell scripts by running:

\begin{Verbatim}
. /etc/functions.sh      # common functions
include /lib/network     # include /lib/network/*.sh
scan_interfaces          # read and parse the network config
\end{Verbatim}

Some protocols, such as PPP might change the configured interface names
at run time (e.g. \texttt{eth0} => \texttt{ppp0} for PPPoE). That's why you have to run
\texttt{scan\_interfaces} instead of reading the values from the config directly.
After running \texttt{scan\_interfaces}, the \texttt{'ifname'} option will always contain
the effective interface name (which is used for IP traffic) and if the
physical device name differs from it, it will be stored in the \texttt{'device'}
option.
That means that running \texttt{config\_get lan ifname}
after \texttt{scan\_interfaces} might not return the same result as running it before.

After running \texttt{scan\_interfaces}, the following functions are available:

\begin{itemize}
    \item{\texttt{find\_config \textit{interface}}} \\
        looks for a network configuration that includes
        the specified network interface.

    \item{\texttt{setup\_interface \textit{interface [config] [protocol]}}} \\
      will set up the specified interface, optionally overriding the network configuration
      name or the protocol that it uses.
\end{itemize}

\subsubsection{Writing protocol handlers}

You can add custom protocol handlers (e.g: PPPoE, PPPoA, ATM, PPTP ...)
by adding shell scripts to \texttt{/lib/network}. They provide the following
two shell functions:

\begin{Verbatim}
scan_<protocolname>() {
    local config="$1"
    # change the interface names if necessary
}

setup_interface_<protocolname>() {
    local interface="$1"
    local config="$2"
    # set up the interface
}
\end{Verbatim}

\texttt{scan\_\textit{protocolname}} is optional and only necessary if your protocol
uses a custom device, e.g. a tunnel or a PPP device.

57ff2af4b2f18abf45a'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit/avr/qmk/uGFX/tree/?id=a70cc09ff9159876edbb157ff2af4b2f18abf45a'>root</a>/<a href='/cgit/avr/qmk/uGFX/tree/drivers?id=a70cc09ff9159876edbb157ff2af4b2f18abf45a'>drivers</a>/<a href='/cgit/avr/qmk/uGFX/tree/drivers/gdisp?id=a70cc09ff9159876edbb157ff2af4b2f18abf45a'>gdisp</a>/<a href='/cgit/avr/qmk/uGFX/tree/drivers/gdisp/ILI9341?id=a70cc09ff9159876edbb157ff2af4b2f18abf45a'>ILI9341</a>/<a href='/cgit/avr/qmk/uGFX/tree/drivers/gdisp/ILI9341/ILI9341.h?id=a70cc09ff9159876edbb157ff2af4b2f18abf45a'>ILI9341.h</a></div><div class='content'>blob: bace69070afb44adad78ffa59e27ea3f0f70b72a (<a href='/cgit/avr/qmk/uGFX/plain/drivers/gdisp/ILI9341/ILI9341.h?id=a70cc09ff9159876edbb157ff2af4b2f18abf45a'>plain</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
<a id='n2' href='#n2'>2</a>
<a id='n3' href='#n3'>3</a>
<a id='n4' href='#n4'>4</a>
<a id='n5' href='#n5'>5</a>
<a id='n6' href='#n6'>6</a>
<a id='n7' href='#n7'>7</a>
<a id='n8' href='#n8'>8</a>
<a id='n9' href='#n9'>9</a>
<a id='n10' href='#n10'>10</a>
<a id='n11' href='#n11'>11</a>
<a id='n12' href='#n12'>12</a>
<a id='n13' href='#n13'>13</a>
<a id='n14' href='#n14'>14</a>
<a id='n15' href='#n15'>15</a>
<a id='n16' href='#n16'>16</a>
<a id='n17' href='#n17'>17</a>
<a id='n18' href='#n18'>18</a>
<a id='n19' href='#n19'>19</a>
<a id='n20' href='#n20'>20</a>
<a id='n21' href='#n21'>21</a>
<a id='n22' href='#n22'>22</a>
<a id='n23' href='#n23'>23</a>
<a id='n24' href='#n24'>24</a>
<a id='n25' href='#n25'>25</a>
<a id='n26' href='#n26'>26</a>
<a id='n27' href='#n27'>27</a>
<a id='n28' href='#n28'>28</a>
<a id='n29' href='#n29'>29</a>
<a id='n30' href='#n30'>30</a>
<a id='n31' href='#n31'>31</a>
<a id='n32' href='#n32'>32</a>
<a id='n33' href='#n33'>33</a>
<a id='n34' href='#n34'>34</a>
<a id='n35' href='#n35'>35</a>
<a id='n36' href='#n36'>36</a>
<a id='n37' href='#n37'>37</a>
<a id='n38' href='#n38'>38</a>
<a id='n39' href='#n39'>39</a>
<a id='n40' href='#n40'>40</a>
<a id='n41' href='#n41'>41</a>
<a id='n42' href='#n42'>42</a>
<a id='n43' href='#n43'>43</a>
<a id='n44' href='#n44'>44</a>
<a id='n45' href='#n45'>45</a>
<a id='n46' href='#n46'>46</a>
<a id='n47' href='#n47'>47</a>
<a id='n48' href='#n48'>48</a>
<a id='n49' href='#n49'>49</a>
<a id='n50' href='#n50'>50</a>
<a id='n51' href='#n51'>51</a>
<a id='n52' href='#n52'>52</a>
<a id='n53' href='#n53'>53</a>
<a id='n54' href='#n54'>54</a>
<a id='n55' href='#n55'>55</a>
<a id='n56' href='#n56'>56</a>
<a id='n57' href='#n57'>57</a>
<a id='n58' href='#n58'>58</a>
<a id='n59' href='#n59'>59</a>
<a id='n60' href='#n60'>60</a>
<a id='n61' href='#n61'>61</a>
<a id='n62' href='#n62'>62</a>
<a id='n63' href='#n63'>63</a>
<a id='n64' href='#n64'>64</a>
<a id='n65' href='#n65'>65</a>
<a id='n66' href='#n66'>66</a>
<a id='n67' href='#n67'>67</a>
<a id='n68' href='#n68'>68</a>
<a id='n69' href='#n69'>69</a>
<a id='n70' href='#n70'>70</a>
<a id='n71' href='#n71'>71</a>
<a id='n72' href='#n72'>72</a>
<a id='n73' href='#n73'>73</a>
<a id='n74' href='#n74'>74</a>
<a id='n75' href='#n75'>75</a>
<a id='n76' href='#n76'>76</a>
<a id='n77' href='#n77'>77</a>
<a id='n78' href='#n78'>78</a>
<a id='n79' href='#n79'>79</a>
<a id='n80' href='#n80'>80</a>
<a id='n81' href='#n81'>81</a>
<a id='n82' href='#n82'>82</a>
<a id='n83' href='#n83'>83</a>
<a id='n84' href='#n84'>84</a>
<a id='n85' href='#n85'>85</a>
<a id='n86' href='#n86'>86</a>
<a id='n87' href='#n87'>87</a>
</pre></td>
<td class='lines'><pre><code><style>pre { line-height: 125%; margin: 0; }
td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #ffffff; }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */</style><div class="highlight"><pre><span></span><span class="cp">#define LCD_VERTICAL_MAX        		320</span>
<span class="cp">#define LCD_HORIZONTAL_MAX      		240</span>

<span class="cp">#define ILI9341_DEVICE_CODE_READ_REG    0x00</span>
<span class="cp">#define ILI9341_SOFT_RESET_REG			0x01</span>
<span class="cp">#define ILI9341_IDENTINFO_R_REG			0x04</span>
<span class="cp">#define ILI9341_STATUS_R_REG			0x09</span>
<span class="cp">#define ILI9341_POWERMODE_R_REG			0x0A</span>
<span class="cp">#define ILI9341_MADCTL_R_REG			0x0B</span>
<span class="cp">#define ILI9341_PIXFORMAT_R_REG			0x0C</span>
<span class="cp">#define ILI9341_IMGFORMAT_R_REG			0x0D</span>
<span class="cp">#define ILI9341_SIGMODE_R_REG			0x0E</span>
<span class="cp">#define ILI9341_SD_RESULT_R_REG			0x0F</span>
<span class="cp">#define ILI9341_SLEEP_ENTER_REG			0x10</span>
<span class="cp">#define ILI9341_SLEEP_OUT_REG			0x11</span>
<span class="cp">#define ILI9341_PARTIALMODE_REG			0x12</span>
<span class="cp">#define ILI9341_NORDISPMODE_REG			0x13</span>
<span class="cp">#define ILI9341_INVERSIONOFF_REG		0x20</span>
<span class="cp">#define ILI9341_INVERSIONON_REG			0x21</span>
<span class="cp">#define ILI9341_GAMMASET_REG			0x26</span>
<span class="cp">#define ILI9341_DISPLAYOFF_REG			0x28</span>
<span class="cp">#define ILI9341_DISPLAYON_REG			0x29</span>
<span class="cp">#define ILI9341_COLADDRSET_REG			0x2A</span>
<span class="cp">#define ILI9341_PAGEADDRSET_REG			0x2B</span>
<span class="cp">#define ILI9341_MEMORYWRITE_REG			0x2C</span>
<span class="cp">#define ILI9341_COLORSET_REG			0x2D</span>
<span class="cp">#define ILI9341_MEMORYREAD_REG			0x2E</span>
<span class="cp">#define ILI9341_PARTIALAREA_REG			0x30</span>
<span class="cp">#define ILI9341_VERTSCROLL_REG			0x33</span>
<span class="cp">#define ILI9341_TEAREFFECTLINEOFF_REG	0x34</span>
<span class="cp">#define ILI9341_TEAREFFECTLINEON_REG	0x35</span>
<span class="cp">#define ILI9341_MEMACCESS_REG			0x36</span>
<span class="cp">#define ILI9341_VERSCRSRART_REG			0x37</span>
<span class="cp">#define ILI9341_IDLEMODEOFF_REG			0x38</span>
<span class="cp">#define ILI9341_IDLEMODEON_REG			0x39</span>
<span class="cp">#define ILI9341_PIXFORMATSET_REG		0x3A</span>
<span class="cp">#define ILI9341_WRITEMEMCONTINUE_REG	0x3C</span>
<span class="cp">#define ILI9341_READMEMCONTINUE_REG		0x3E</span>
<span class="cp">#define ILI9341_SETTEATSCAN_REG			0x44</span>
<span class="cp">#define ILI9341_GETSCANLINE_REG			0x45</span>
<span class="cp">#define ILI9341_WRITEBRIGHT_REG			0x51</span>
<span class="cp">#define ILI9341_READBRIGHT_REG			0x52</span>
<span class="cp">#define ILI9341_WRITECTRL_REG			0x53</span>
<span class="cp">#define ILI9341_READCTRL_REG			0x54</span>
<span class="cp">#define ILI9341_WRITECABC_REG			0x55</span>
<span class="cp">#define ILI9341_READCABC_REG			0x56</span>
<span class="cp">#define ILI9341_WRITECABCMB_REG			0x5E</span>
<span class="cp">#define ILI9341_READCABCMB_REG			0x5F</span>
<span class="cp">#define ILI9341_RGB_ISCTL_REG			0xB0</span>
<span class="cp">#define ILI9341_FRAMECTL_NOR_REG		0xB1</span>
<span class="cp">#define ILI9341_FRAMECTL_IDLE_REG		0xB2</span>
<span class="cp">#define ILI9341_FRAMECTL_PARTIAL_REG	0xB3</span>
<span class="cp">#define ILI9341_INVERCTL_REG			0xB4</span>
<span class="cp">#define ILI9341_BLANKPORCTL_REG			0xB5</span>
<span class="cp">#define ILI9341_FUNCTONCTL_REG			0xB6</span>
<span class="cp">#define ILI9341_ENTRYMODE_REG			0xB7</span>
<span class="cp">#define ILI9341_BLIGHTCTL1_REG			0xB8</span>
<span class="cp">#define ILI9341_BLIGHTCTL2_REG			0xB9</span>
<span class="cp">#define ILI9341_BLIGHTCTL3_REG			0xBA</span>
<span class="cp">#define ILI9341_BLIGHTCTL4_REG			0xBB</span>
<span class="cp">#define ILI9341_BLIGHTCTL5_REG			0xBC</span>
<span class="cp">#define ILI9341_BLIGHTCTL7_REG			0xBE</span>
<span class="cp">#define ILI9341_BLIGHTCTL8_REG			0xBF</span>
<span class="cp">#define ILI9341_POWERCTL1_REG			0xC0</span>
<span class="cp">#define ILI9341_POWERCTL2_REG			0xC1</span>
<span class="cp">#define ILI9341_VCOMCTL1_REG			0xC5</span>
<span class="cp">#define ILI9341_VCOMCTL2_REG			0xC7</span>
<span class="cp">#define ILI9341_POWERCTLA_REG			0xCB</span>
<span class="cp">#define ILI9341_POWERCTLB_REG			0xCF</span>
<span class="cp">#define ILI9341_NVMEMWRITE_REG			0xD0</span>
<span class="cp">#define ILI9341_NVMEMPROTECTKEY_REG		0xD1</span>
<span class="cp">#define ILI9341_NVMEMSTATUS_REG			0xD2</span>
<span class="cp">#define ILI9341_READID4_REG				0xD3</span>
<span class="cp">#define ILI9341_READID1_REG				0xDA</span>
<span class="cp">#define ILI9341_READID2_REG				0xDB</span>
<span class="cp">#define ILI9341_READID3_REG				0xDC</span>
<span class="cp">#define ILI9341_POSGAMMACORRECTION_REG	0xE0</span>
<span class="cp">#define ILI9341_NEGGAMMACORRECTION_REG	0xE1</span>
<span class="cp">#define ILI9341_DIGGAMCTL1_REG			0xE2</span>
<span class="cp">#define ILI9341_DIGGAMCTL2_REG			0xE3</span>
<span class="cp">#define ILI9341_DIVTIMCTL_A_REG			0xE8</span>
<span class="cp">#define ILI9341_DIVTIMCTL_B_REG			0xEA</span>
<span class="cp">#define ILI9341_POWONSEQCTL_REG			0xED</span>
<span class="cp">#define ILI9341_ENABLE_3G_REG			0xF2</span>
<span class="cp">#define ILI9341_INTERFCTL_REG			0xF6</span>
<span class="cp">#define ILI9341_PUMPRATIOCTL_REG		0xF7</span>
</pre></div>
</code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3</a> (<a href='https://git-scm.com/'>git 2.25.1</a>) at 2025-03-24 12:09:24 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>