<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.xsl" type="text/xsl"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	     xmlns:dc="http://purl.org/dc/elements/1.1/"
	   xmlns:atom="http://www.w3.org/2005/Atom"
	     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>c++ &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Sun, 09 Jul 2023 15:05:29 +0000</lastBuildDate>
	<language>en-GB</language>
	<copyright>© Terence Eden. 🄯 CC BY-SA. See https://shkspr.mobi/blog/copyright-and-copyleft/</copyright>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>c++ &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[How to make the Watchy vibrate]]></title>
		<link>https://shkspr.mobi/blog/2023/07/how-to-make-the-watchy-vibrate/</link>
					<comments>https://shkspr.mobi/blog/2023/07/how-to-make-the-watchy-vibrate/#comments</comments>
				<dc:creator><![CDATA[Terence Eden]]></dc:creator>
		<pubDate>Sun, 09 Jul 2023 11:34:42 +0000</pubDate>
		<category><![CDATA[arduino]]></category><category><![CDATA[c++]]></category><category><![CDATA[HowTo]]></category><category><![CDATA[tutorial]]></category><category><![CDATA[watchy]]></category>		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=46247</guid>

					<description><![CDATA[I am enjoying playing with the eInk Watchy. It is a cute package and is everything I want in a Smart-Watch; geeky, long battery life, and not obnoxious.  But - fuck me! - the documentation is atrocious! Well, that&#039;s a lie. There is no documentation. It has the &#34;Chat to us on Discord&#34; anti-pattern that infects so many otherwise great projects.  So I&#039;m left to figure out how to make the Watchy&#039;s…]]></description>
										<content:encoded>&lt;p&gt;I am enjoying playing with the eInk Watchy. It is a cute package and is everything I want in a Smart-Watch; geeky, long battery life, and not obnoxious.&lt;/p&gt;

&lt;p&gt;But - fuck me! - the documentation is atrocious! Well, that's a lie. There is no documentation. It has the "Chat to us on Discord" anti-pattern that infects so many otherwise great projects.&lt;/p&gt;

&lt;p&gt;So I'm left to figure out how to make the Watchy's haptics work.&lt;/p&gt;

&lt;p&gt;The example watchfaces have a file called &lt;code&gt;settings.h&lt;/code&gt; which contains &lt;a href="https://github.com/sqfmi/Watchy/blob/342eb48a497eb3dcb1ec03c5c156937fdec07ba9/examples/WatchFaces/7_SEG/settings.h#L24"&gt;&lt;code&gt;.vibrateOClock = true&lt;/code&gt;&lt;/a&gt;. Set that and you'll get a little buzz on the hour, &lt;em&gt;every&lt;/em&gt; hour.&lt;/p&gt;

&lt;p&gt;But how do you make it buzz when you've hit your step-count goal? Or when the time is 13:37? Or whenever &lt;em&gt;you&lt;/em&gt; want?&lt;/p&gt;

&lt;p&gt;There's no documentation. And searching the code for "vibrate" or "vibe" or "vibration" yielded nothing.  But I accidentally typo'd my search and entered "vib" - and that did the trick.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;config.h&lt;/code&gt; there's this line: &lt;a href="https://github.com/sqfmi/Watchy/blob/342eb48a497eb3dcb1ec03c5c156937fdec07ba9/src/config.h#L25"&gt;&lt;code&gt;#define VIB_MOTOR_PIN 13&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So, pin 13 is wired in to the vibration motor. We can add that line to our own config file. But how do we turn the buzzer on and off?&lt;/p&gt;

&lt;p&gt;With a bit of help from Discord, it became clear:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-c"&gt;pinMode(VIB_MOTOR_PIN, OUTPUT);     // Set vibration motor pin as an output.
digitalWrite(VIB_MOTOR_PIN, true);  // Enable vibration motor
delay(150);                         // Vibe for 150 ms.
digitalWrite(VIB_MOTOR_PIN, false); // Disable vibration motor.
delay(500);                         // Wait half a second
digitalWrite(VIB_MOTOR_PIN, true);  // Enable vibration motor
delay(250);                         // Vibe for quarter of a second
digitalWrite(VIB_MOTOR_PIN, false); // Stop vibrating
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That's the same as the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vibrate"&gt;HTML5 Vibrate API&lt;/a&gt; - you can't control the intensity, but you can &lt;a href="https://shkspr.mobi/blog/2014/01/malicious-use-of-the-html5-vibrate-api/"&gt;program your own vibration patterns&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I just don't understand why hardware vendors are &lt;em&gt;so&lt;/em&gt; crap at writing documentation. Don't they like people using their products?&lt;/p&gt;
&lt;img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=46247&amp;amp;HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager"&gt;</content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2023/07/how-to-make-the-watchy-vibrate/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
