Finally

Illustration

Both Windows 8 and Visual Studio 2012 are finally available to MSDN subscribers.

I already got leaked versions from the torrents so this was just great opportunity to check whether SHA-1 matches. Guess what, it does. :)

Since everybody is trying to download these images right now, torrent also gives better experience.

Same general slowness and server crashes are nothing new for MSDN site (remember Windows 7). Maybe Microsoft should just embrace torrent network as distribution media instead relying on its own (obviously inadequate) infrastructure…

Is It Dark Yet?

Themes are quite popular thing under Windows and it is very hard to make an application that would look decent regardless of user-selected colors. It is somewhat easier when you can cover all your needs with predefined theme colors. but sometime you just need a few more in order to emphasize an element.

As an example we can take simple highlighting of an error. Changing offending text to dark red works really nice on white background. If user has dark background, dark red text is probably not as visible.

Easiest solution (and I fear most often used one) is to ignore this issue. If user has such stupid theme, it is his problem. Needless to say, this is very rude. If user wants to have black background, user should have it. Lunatics should not be restricted!

Other solution is to find colors for every combination expected in wild. Given customization possibilities this is probably not a path worth taking. However, we can divide all possible theme choices into subsets and work from there.

I usually just fit everything into two color buckets - light and dark. If I detect that background is light, I use one color, while I use another if background is dark. This simple solution works almost always.

Function looks something like this:

bool IsColorDark(Color color) {
    var y = 0.2126 * color.R + 0.7152 * color.G + 0.0722 * color.B;
    return (y <= 160);
}

It just calculates luminance of a given color (0-255). All colors with high luminance are considered light and all those with low luminance are dark. Somewhat arbitrary cutoff point value used here is 160. I found that it works quite well for my needs.

To check whether color belongs on dark end of spectrum we just place it in function call:

if (IsColorDark(myColor)) {
    //do something for dark
} else {
    //do something for light
}

Why the Wait?

I am MSDN subscriber and I am currently paying for it myself. That gives me privilege of being among first ones to download newest Windows and Visual Studio.

For example, Windows 8 went RTM on August 1st and I can get it on August 15th; Visual Studio 2012 went RTM on 3rd and I will get it on 15th. Public usually gets things few weeks afterward.

I am more than annoyed by the fact that it takes Microsoft two weeks to make RTM available for download without any good reason. Image is ready, pirates already have a copy. Why not release it for download? What is there to lose?

Way I see it, MSDN customers are either big companies which will probably install your new stuff in ten years or enthusiasts that want download now. Early release does not mean much to companies but it means everything to an enthusiast. If pirates can get software sooner, why bother paying MSDN?

Sometime I just feel like a money-wasting idiot…

Elusive CONFIG3H Setting

For toy project of mine I wanted to test PIC18F13K50. Nice fast PIC, lot of RAM, some ROM and USB connectivity. All that while working on good old 5V.

First order of business was to set configuration bits. Code should be familiar to anyone who used XC8:

#pragma config HFOFST = OFF
#pragma config MCLRE  = OFF

Unfortunately that did not work. I could set all bits other than those in CONFIG3H. And thus I could not make MCLR pin behave as normal input. Since PCB was already done, I could not just opt to use other pin. I had to have it my way.

I also tried to use:

__CONFIG(_CONFIG3H, HFOFST_OFF & MCLRE_OFF);

Hell, I even tried

 __PROG_CONFIG(3, 0x00);
```]

Nothing worked.

And than I noticed a curious thing. This PIC has CONFIG2H register followed by CONFIG3H. There is no CONFIG3L. Could that be an issue?

On a hunch I went to edit `18f13k50.cfgdata` (in `C:\Program Files\Microchip\xc8\v1.01\dat\`). There I added single line (highlighted) just before CONFIG3H declaration:

```plain
CWORD:300004:00:00:CONFIG3L
CWORD:300005:88:88:CONFIG3H
CSETTING:8:HFOFST:HFINTOSC Fast Start-up bit
CVALUE:8:ON:HFINTOSC starts clocking the CPU without waiting for the oscillator to stablize.
CVALUE:0:OFF:The system clock is held off until the HFINTOSC is stable.
CSETTING:80:MCLRE:MCLR Pin Enable bit
CVALUE:80:ON:MCLR pin enabled; RA3 input pin disabled
CVALUE:0:OFF:RA3 input pin enabled; MCLR disabled

With that simple change all was well and configuration bits were set.

And it works!

P.S. This workaround is valid for all other 18F family PICs that have CONFIG3L missing (e.g. PIC18F1220, PIC18F14K50…).

P.P.S. This should be solved in XC 1.10. Let’s hope. :)

[2012-08-11: As of XC8 1.10 this issue is fixed.]

No More Metro

Illustration

Those who are annoyed with Metro UI can rejojce. Microsoft will not use Metro interface for Windows 8.

Just joking, there is no real change here. Somehow Microsoft managed to step into trademark turd and now it is backpedaling out of it. I can imagine some poor guy going through all documentation, all articles and God knows what else (Windows 8 manual maybe) in order to replace any mention of Metro with “Windows 8-style UI”.

Windows Mobile related documents will get same treatment. With one stroke of a pen it will get it’s “New User Interface”. A bit stupid name for second iteration of same UI, but I guess that happens when lawyers crash the party.

While it might be funny to see Microsoft fry a bit, I do wonder why there is trademark issue here at all. Is the world going crazy?

[2012-10-05: Lately Microsoft started to refer to interface as Modern UI. Strangely appropriate since I feel like I am in Modern Times while using it.]