Every content here is my original work.Creative Commons Licence
Universitas Scripta is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Your cookies may be used by Google and mathjax. See Google's privacy policy.

Friday 26 March 2021

Baseus Charger may damage your iPad

Seems some ESD? cause iPad malfunction during charging by Baseus 65W 2C1A charger. I am scary that this may someday damage my iPad. I continued to use it because another Baseus charger is USB-IF certified (no dual charger is certified. Maybe dual charging chip is outside of the standard in any way.) But now my Apple Pencil started to glitch all over the screen to I may have to stop to use.

Monday 22 March 2021

CMAttitude singularity

 By experiment, you can figure out q = (cos(yaw/2) + k sin(yaw/2)) * (cos(pitch/2) + i sin(pitch/2)) * (cos(roll/2) + j sin(roll/2)) where yaw and roll are in \([-\pi, \pi]\) and pitch is in \([-\pi/2, \pi/2]\). 

Since quaternion <-> rotation matrix is not one-to-one, we have to play with original expression, matrix. As apple's rotation matrix is active rotation, (current rotation matrix) = (relative matrix) * (reference frame rotation matrix). This gives proper singular points, 90deg and -90deg pitch from the reference attitude. If you just use quaternion i.e. CMAttitude system API, singularities are at the fixed point, absolute 90, -90deg pitch point. 90deg pitch point is right at the attitude when you are holding phone right up, which is pretty annoying.

little tips to close overlay on SwiftUI

 This is about the architecture of SwiftUI.

Objective: I want to open and close little overlay message box.

When closed, I don't want to use system resource, and additionally I'll be happy if I can use onAppear and onDisappear.

Also, I want my closing animation work properly.

Implementation:

1. Use complete object destruction by defining 

func View.overlay(_ view: View?) -> View {
    if view == nil{
        self
    }else{
        self.overlay(view)
    }
}

In this way, when I started closing animation by withAnimation{overlayView = nil}, the screen shows preview of the main view, so I see all the blinks and glitches.

2. opacity -> 0

By this method, I am worried that I cannot achieve the objective. It is wasting my resources and I think I cannot use onDisappear.

3. hidden(_ bool: Bool)

Define this function for View. This worked perfectly so I did not tested 2nd option. I think this is supposed to do, designed by Apple developers.

In this way, onAppear is called *when the mainview.overlay() is called * when overlay is unhidden *but not when overlay is not completely hidden but new appearance is called. onDisappear is called *when overlay is completely hidden (end of animation) *but not when overlay hiding animation is over but new overlay unhiding is called.

Wednesday 10 March 2021

iOS 14.4.1 critical bug

 Local paths are inaccessible in Files app. When you try to access it, app freezes.

Sunday 7 March 2021

Calculation of crosstalk in common ground cable (e.g. 3.5mm)

 Cross talk is roughly the voltage difference made by the resistance of common ground cable.

For example, let's assume AWG 24 1m cable. Single thread of it has R_(CG)=83.4mOhm.

Also let's assume 75dBA listening sound in 105dB/mW, R=47Ohm headphone.

Then, V = 6.856mV = -43dBV = -41dBu 

I = 145.9uA.

The crosstalk = I*R_(CG)/V = R_(CG)/R. (in voltage ratio i.e. dB = 20 log(V/V))

If we aim for -85dB crosstalk in 47ohm headphone, 3.5mm cable must have less than 2.6mOhm.

This is from TI's crosstalk guideline.

83.4mOhm is 32x of 2.6mOhm so -85dB+30dB = -55dB crosstalk in 47ohm headphone with AWG24 1m cable.


One more example. Take best case Silver AWG18 0.5m cable. Cable resistance is 10mOhm. Take 600Ohm headphone. Then the crosstalk is 20log(0.01/600) = -96dB.

Difference between copper and silver is 0.5dB. Best thing to do is to make sure cable thick.